]> source.dussan.org Git - aspectj.git/blob
73ffafee39f590d9f3d70bbe3a90e5d597581747
[aspectj.git] /
1 /* *******************************************************************
2  * Copyright (c) 2003 Contributors.
3  * All rights reserved. 
4  * This program and the accompanying materials are made available 
5  * under the terms of the Eclipse Public License v1.0 
6  * which accompanies this distribution and is available at 
7  * http://www.eclipse.org/legal/epl-v10.html 
8  *  
9  * Contributors: 
10  *     Mik Kersten     initial implementation 
11  * ******************************************************************/
12  
13 package org.aspectj.ajdt.internal.compiler.lookup;
14
15 //import java.io.IOException;
16
17 import org.aspectj.asm.AsmManager;
18 import org.aspectj.asm.IRelationship;
19 import org.aspectj.asm.IRelationshipMap;
20 import org.aspectj.weaver.ResolvedType;
21
22 /**
23  * !!! is this class still being used?
24  * 
25  * @author Mik Kersten
26  */
27 public class AsmInterTypeRelationshipProvider {
28
29     protected static AsmInterTypeRelationshipProvider INSTANCE = new AsmInterTypeRelationshipProvider();
30     
31         public static final String INTER_TYPE_DECLARES = "declared on";
32         public static final String INTER_TYPE_DECLARED_BY = "aspect declarations";
33
34         public void addRelationship(
35                 ResolvedType onType,
36                 EclipseTypeMunger munger) {
37                         
38 //              IProgramElement.Kind kind = IProgramElement.Kind.ERROR;
39 //              if (munger.getMunger().getKind() == ResolvedTypeMunger.Field) {
40 //                      kind = IProgramElement.Kind.INTER_TYPE_FIELD;
41 //              } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Constructor) {
42 //                      kind = IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR;
43 //              } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Method) {
44 //                      kind = IProgramElement.Kind.INTER_TYPE_METHOD;
45 //              } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Parent) {
46 //                      kind = IProgramElement.Kind.INTER_TYPE_PARENT;
47 //              }        
48         
49                 if (munger.getSourceLocation() != null
50                         && munger.getSourceLocation() != null) {
51                         String sourceHandle = AsmManager.getDefault().getHandleProvider().createHandleIdentifier(
52                                 munger.getSourceLocation().getSourceFile(),
53                                 munger.getSourceLocation().getLine(),
54                                 munger.getSourceLocation().getColumn(),
55                                 munger.getSourceLocation().getOffset());
56                                 
57                         String targetHandle = AsmManager.getDefault().getHandleProvider().createHandleIdentifier(
58                                 onType.getSourceLocation().getSourceFile(),
59                                 onType.getSourceLocation().getLine(),
60                                 onType.getSourceLocation().getColumn(),
61                                 onType.getSourceLocation().getOffset());
62                                 
63                         IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
64                         if (sourceHandle != null && targetHandle != null) {
65                                 IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARES,false,true);
66                                 foreward.addTarget(targetHandle);
67                                 
68                                 IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARED_BY,false,true);
69                                 back.addTarget(sourceHandle);
70                         }
71                 }
72         }
73         
74     public static AsmInterTypeRelationshipProvider getDefault() {
75         return INSTANCE;
76     }
77     
78     /**
79      * Reset the instance of this class, intended for extensibility.
80      * This enables a subclass to become used as the default instance.
81      */
82     public static void setDefault(AsmInterTypeRelationshipProvider instance) {
83         INSTANCE = instance;
84     }
85 }