1 /* *******************************************************************
2 * Copyright (c) 2005 Contributors
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
10 * Andy Clement promoted member type from AjState
11 * ******************************************************************/
12 package org.aspectj.ajdt.internal.core.builder;
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;
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.
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];
38 // this is the core state for comparison
41 char[] genericSignature;
42 char[] superclassName;
45 char[] enclosingMethod;
47 char[][][] missingTypeNames;
49 // this is the extra state that enables us to be an IBinaryType
50 char[] enclosingTypeName;
51 boolean isLocal, isAnonymous, isMember;
52 char[] sourceFileName;
57 IBinaryField[] binFields;
58 IBinaryMethod[] binMethods;
59 IBinaryNestedType[] memberTypes;
60 IBinaryAnnotation[] annotations;
61 IBinaryTypeAnnotation[] typeAnnotations;
64 public CompactTypeStructureRepresentation(ClassFileReader cfr, boolean isAspect) {
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) {
80 this.binMethods = cfr.getMethods();
81 if (binMethods == null) {
82 binMethods = NoMethod;
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;
98 this.superclassName = cfr.getSuperclassName(); // slashes...
99 interfaces = cfr.getInterfaceNames();
103 public char[][][] getMissingTypeNames() {
104 return missingTypeNames;
107 public char[] getEnclosingTypeName() {
108 return enclosingTypeName;
111 public int getModifiers() {
115 public char[] getGenericSignature() {
116 return genericSignature;
119 public char[] getEnclosingMethod() {
120 return enclosingMethod;
123 public char[][] getInterfaceNames() {
127 public boolean isAnonymous() {
131 public char[] sourceFileName() {
132 return sourceFileName;
135 public boolean isLocal() {
139 public boolean isMember() {
143 public char[] getSuperclassName() {
144 return superclassName;
147 public char[] getFileName() {
151 public char[] getName() {
155 public long getTagBits() {
159 public boolean isBinaryType() {
163 public IBinaryField[] getFields() {
167 public IBinaryMethod[] getMethods() {
171 public IBinaryNestedType[] getMemberTypes() {
175 public IBinaryAnnotation[] getAnnotations() {
179 public char[] getSourceName() {
183 public IBinaryTypeAnnotation[] getTypeAnnotations() {
184 return typeAnnotations;
187 public ITypeAnnotationWalker enrichWithExternalAnnotationsFor(ITypeAnnotationWalker walker, Object member,
188 LookupEnvironment environment) {
189 // TODO[1.8.7] more to do here? In what contexts?
193 public char[] getModule() {
194 // TODO Auto-generated method stub
198 public ExternalAnnotationStatus getExternalAnnotationStatus() {
199 return ExternalAnnotationStatus.NOT_EEA_CONFIGURED;