]> source.dussan.org Git - aspectj.git/blob
e1d931196d1cb0cf6c4395a3ae4cf53e4903824d
[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
22 /**
23  * Used to determine if a type has structurally changed during incremental compilation. At the end of compilation we create one of
24  * these objects using the bytes for the class about to be woven. On a subsequent incremental compile we compare the new form of the
25  * class with a previously stored CompactTypeStructureRepresentation instance. A structural change will indicate we need to do
26  * recompile other dependent types.
27  */
28 public class CompactTypeStructureRepresentation implements IBinaryType {
29         static char[][] NoInterface = CharOperation.NO_CHAR_CHAR;
30         static IBinaryNestedType[] NoNestedType = new IBinaryNestedType[0];
31         static IBinaryField[] NoField = new IBinaryField[0];
32         static IBinaryMethod[] NoMethod = new IBinaryMethod[0];
33
34         // this is the core state for comparison
35         char[] className;
36         int modifiers;
37         char[] genericSignature;
38         char[] superclassName;
39         char[][] interfaces;
40
41         // this is the extra state that enables us to be an IBinaryType
42         char[] enclosingTypeName;
43         boolean isLocal, isAnonymous, isMember;
44         char[] sourceFileName;
45         char[] fileName;
46         char[] sourceName;
47         long tagBits;
48         boolean isBinaryType;
49         IBinaryField[] binFields;
50         IBinaryMethod[] binMethods;
51         IBinaryNestedType[] memberTypes;
52         IBinaryAnnotation[] annotations;
53
54         public CompactTypeStructureRepresentation(ClassFileReader cfr) {
55
56                 this.enclosingTypeName = cfr.getEnclosingTypeName();
57                 this.isLocal = cfr.isLocal();
58                 this.isAnonymous = cfr.isAnonymous();
59                 this.isMember = cfr.isMember();
60                 this.sourceFileName = cfr.sourceFileName();
61                 this.fileName = cfr.getFileName();
62                 this.tagBits = cfr.getTagBits();
63                 this.isBinaryType = cfr.isBinaryType();
64                 this.binFields = cfr.getFields();
65                 if (binFields == null) {
66                         binFields = NoField;
67                 }
68                 this.binMethods = cfr.getMethods();
69                 if (binMethods == null) {
70                         binMethods = NoMethod;
71                 }
72                 this.memberTypes = cfr.getMemberTypes();
73                 this.annotations = cfr.getAnnotations();
74                 this.sourceName = cfr.getSourceName();
75                 this.className = cfr.getName(); // slashes...
76                 this.modifiers = cfr.getModifiers();
77                 this.genericSignature = cfr.getGenericSignature();
78                 // if (this.genericSignature.length == 0) {
79                 // this.genericSignature = null;
80                 // }
81                 this.superclassName = cfr.getSuperclassName(); // slashes...
82                 interfaces = cfr.getInterfaceNames();
83
84         }
85
86         public char[] getEnclosingTypeName() {
87                 return enclosingTypeName;
88         }
89
90         public int getModifiers() {
91                 return modifiers;
92         }
93
94         public char[] getGenericSignature() {
95                 return genericSignature;
96         }
97
98         public char[][] getInterfaceNames() {
99                 return interfaces;
100         }
101
102         public boolean isAnonymous() {
103                 return isAnonymous;
104         }
105
106         public char[] sourceFileName() {
107                 return sourceFileName;
108         }
109
110         public boolean isLocal() {
111                 return isLocal;
112         }
113
114         public boolean isMember() {
115                 return isMember;
116         }
117
118         public char[] getSuperclassName() {
119                 return superclassName;
120         }
121
122         public char[] getFileName() {
123                 return fileName;
124         }
125
126         public char[] getName() {
127                 return className;
128         }
129
130         public long getTagBits() {
131                 return tagBits;
132         }
133
134         public boolean isBinaryType() {
135                 return isBinaryType;
136         }
137
138         public IBinaryField[] getFields() {
139                 return binFields;
140         }
141
142         public IBinaryMethod[] getMethods() {
143                 return binMethods;
144         }
145
146         public IBinaryNestedType[] getMemberTypes() {
147                 return memberTypes;
148         }
149
150         public IBinaryAnnotation[] getAnnotations() {
151                 return annotations;
152         }
153
154         public char[] getSourceName() {
155                 return sourceName;
156         }
157
158 }