]> source.dussan.org Git - aspectj.git/blob
ad43d9ee9691c8ffb4d1b6c854743185c427f7b3
[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 Common Public License v1.0 
6  * which accompanies this distribution and is available at 
7  * http://www.eclipse.org/legal/cpl-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.*;
18 import org.aspectj.asm.internal.ProgramElement;
19 import org.aspectj.weaver.*;
20
21 /**
22  * !!! is this class still being used?
23  * 
24  * @author Mik Kersten
25  */
26 public class AsmInterTypeRelationshipProvider {
27
28     protected static AsmInterTypeRelationshipProvider INSTANCE = new AsmInterTypeRelationshipProvider();
29     
30         public static final String INTER_TYPE_DECLARES = "declared on";
31         public static final String INTER_TYPE_DECLARED_BY = "aspect declarations";
32
33         public void addRelationship(
34                 ResolvedTypeX onType,
35                 EclipseTypeMunger munger) {
36                         
37 //              IProgramElement.Kind kind = IProgramElement.Kind.ERROR;
38 //              if (munger.getMunger().getKind() == ResolvedTypeMunger.Field) {
39 //                      kind = IProgramElement.Kind.INTER_TYPE_FIELD;
40 //              } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Constructor) {
41 //                      kind = IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR;
42 //              } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Method) {
43 //                      kind = IProgramElement.Kind.INTER_TYPE_METHOD;
44 //              } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Parent) {
45 //                      kind = IProgramElement.Kind.INTER_TYPE_PARENT;
46 //              }        
47         
48                 if (munger.getSourceLocation() != null
49                         && munger.getSourceLocation() != null) {
50                         String sourceHandle = ProgramElement.createHandleIdentifier(
51                                 munger.getSourceLocation().getSourceFile(),
52                                 munger.getSourceLocation().getLine(),
53                                 munger.getSourceLocation().getColumn());
54                                 
55                         String targetHandle = ProgramElement.createHandleIdentifier(
56                                 onType.getSourceLocation().getSourceFile(),
57                                 onType.getSourceLocation().getLine(),
58                                 onType.getSourceLocation().getColumn());
59                                 
60                         IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
61                         if (sourceHandle != null && targetHandle != null) {
62                                 IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARES,false,true);
63                                 foreward.addTarget(targetHandle);
64                                 
65                                 IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARED_BY,false,true);
66                                 back.addTarget(sourceHandle);
67                         }
68                 }
69         }
70         
71     public static AsmInterTypeRelationshipProvider getDefault() {
72         return INSTANCE;
73     }
74     
75     /**
76      * Reset the instance of this class, intended for extensibility.
77      * This enables a subclass to become used as the default instance.
78      */
79     public static void setDefault(AsmInterTypeRelationshipProvider instance) {
80         INSTANCE = instance;
81     }
82 }