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