]> source.dussan.org Git - aspectj.git/blob
2e4001e073f25c00fe542f61da7ddb8f0ec492e3
[aspectj.git] /
1 /* *******************************************************************
2  * Copyright (c) 2005 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  *     Andy Clement   promoted member type from AjState
11  * ******************************************************************/
12 package org.aspectj.ajdt.internal.core.builder;
13
14 import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
15 import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
16 import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
17 import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryField;
18 import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
19 import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
20 import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType;
21 import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation;
22 import org.aspectj.org.eclipse.jdt.internal.compiler.env.ITypeAnnotationWalker;
23 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
24 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
25
26 /**
27  * Used to determine if a type has structurally changed during incremental compilation. At the end of compilation we create one of
28  * these objects using the bytes for the class about to be woven. On a subsequent incremental compile we compare the new form of the
29  * class with a previously stored CompactTypeStructureRepresentation instance. A structural change will indicate we need to do
30  * recompile other dependent types.
31  */
32 public class CompactTypeStructureRepresentation implements IBinaryType {
33         static char[][] NoInterface = CharOperation.NO_CHAR_CHAR;
34         static IBinaryNestedType[] NoNestedType = new IBinaryNestedType[0];
35         static IBinaryField[] NoField = new IBinaryField[0];
36         static IBinaryMethod[] NoMethod = new IBinaryMethod[0];
37
38         // this is the core state for comparison
39         char[] className;
40         int modifiers;
41         char[] genericSignature;
42         char[] superclassName;
43         char[][] interfaces;
44
45         char[] enclosingMethod;
46
47         char[][][] missingTypeNames;
48
49         // this is the extra state that enables us to be an IBinaryType
50         char[] enclosingTypeName;
51         boolean isLocal, isAnonymous, isMember;
52         char[] sourceFileName;
53         char[] fileName;
54         char[] sourceName;
55         long tagBits;
56         boolean isBinaryType;
57         IBinaryField[] binFields;
58         IBinaryMethod[] binMethods;
59         IBinaryNestedType[] memberTypes;
60         IBinaryAnnotation[] annotations;
61         IBinaryTypeAnnotation[] typeAnnotations;
62
63
64         public CompactTypeStructureRepresentation(ClassFileReader cfr, boolean isAspect) {
65
66                 this.enclosingTypeName = cfr.getEnclosingTypeName();
67                 this.isLocal = cfr.isLocal();
68                 this.isAnonymous = cfr.isAnonymous();
69                 this.isMember = cfr.isMember();
70                 this.sourceFileName = cfr.sourceFileName();
71                 this.fileName = cfr.getFileName();
72                 this.missingTypeNames = cfr.getMissingTypeNames();
73                 this.tagBits = cfr.getTagBits();
74                 this.enclosingMethod = cfr.getEnclosingMethod();
75                 this.isBinaryType = cfr.isBinaryType();
76                 this.binFields = cfr.getFields();
77                 if (binFields == null) {
78                         binFields = NoField;
79                 }
80                 this.binMethods = cfr.getMethods();
81                 if (binMethods == null) {
82                         binMethods = NoMethod;
83                 }
84                 // If we are an aspect we (for now) need to grab even the malformed inner type info as it
85                 // may be there because it refers to an ITD'd innertype. This needs to be improved - perhaps
86                 // using a real attribute against which memberTypes can be compared to see which are just
87                 // references and which were real declarations
88                 this.memberTypes = cfr.getMemberTypes(isAspect);
89                 this.annotations = cfr.getAnnotations();
90                 this.typeAnnotations = cfr.getTypeAnnotations();
91                 this.sourceName = cfr.getSourceName();
92                 this.className = cfr.getName(); // slashes...
93                 this.modifiers = cfr.getModifiers();
94                 this.genericSignature = cfr.getGenericSignature();
95                 // if (this.genericSignature.length == 0) {
96                 // this.genericSignature = null;
97                 // }
98                 this.superclassName = cfr.getSuperclassName(); // slashes...
99                 interfaces = cfr.getInterfaceNames();
100
101         }
102
103         public char[][][] getMissingTypeNames() {
104                 return missingTypeNames;
105         }
106
107         public char[] getEnclosingTypeName() {
108                 return enclosingTypeName;
109         }
110
111         public int getModifiers() {
112                 return modifiers;
113         }
114
115         public char[] getGenericSignature() {
116                 return genericSignature;
117         }
118
119         public char[] getEnclosingMethod() {
120                 return enclosingMethod;
121         }
122
123         public char[][] getInterfaceNames() {
124                 return interfaces;
125         }
126
127         public boolean isAnonymous() {
128                 return isAnonymous;
129         }
130
131         public char[] sourceFileName() {
132                 return sourceFileName;
133         }
134
135         public boolean isLocal() {
136                 return isLocal;
137         }
138
139         public boolean isMember() {
140                 return isMember;
141         }
142
143         public char[] getSuperclassName() {
144                 return superclassName;
145         }
146
147         public char[] getFileName() {
148                 return fileName;
149         }
150
151         public char[] getName() {
152                 return className;
153         }
154
155         public long getTagBits() {
156                 return tagBits;
157         }
158
159         public boolean isBinaryType() {
160                 return isBinaryType;
161         }
162
163         public IBinaryField[] getFields() {
164                 return binFields;
165         }
166
167         public IBinaryMethod[] getMethods() {
168                 return binMethods;
169         }
170
171         public IBinaryNestedType[] getMemberTypes() {
172                 return memberTypes;
173         }
174
175         public IBinaryAnnotation[] getAnnotations() {
176                 return annotations;
177         }
178
179         public char[] getSourceName() {
180                 return sourceName;
181         }
182
183         public IBinaryTypeAnnotation[] getTypeAnnotations() {
184                 return typeAnnotations;
185         }
186
187         public ITypeAnnotationWalker enrichWithExternalAnnotationsFor(ITypeAnnotationWalker walker, Object member,
188                         LookupEnvironment environment) {
189                 // TODO[1.8.7] more to do here? In what contexts?
190                 return walker;
191         }
192
193         public char[] getModule() {
194                 // TODO Auto-generated method stub
195                 return null;
196         }
197
198         public ExternalAnnotationStatus getExternalAnnotationStatus() {
199                 return ExternalAnnotationStatus.NOT_EEA_CONFIGURED;
200         }
201
202 }