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;
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.
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];
35 // this is the core state for comparison
38 char[] genericSignature;
39 char[] superclassName;
42 char[] enclosingMethod;
44 char[][][] missingTypeNames;
46 // this is the extra state that enables us to be an IBinaryType
47 char[] enclosingTypeName;
48 boolean isLocal, isAnonymous, isMember;
49 char[] sourceFileName;
54 IBinaryField[] binFields;
55 IBinaryMethod[] binMethods;
56 IBinaryNestedType[] memberTypes;
57 IBinaryAnnotation[] annotations;
58 IBinaryTypeAnnotation[] typeAnnotations;
61 public CompactTypeStructureRepresentation(ClassFileReader cfr, boolean isAspect) {
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) {
77 this.binMethods = cfr.getMethods();
78 if (binMethods == null) {
79 binMethods = NoMethod;
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;
95 this.superclassName = cfr.getSuperclassName(); // slashes...
96 interfaces = cfr.getInterfaceNames();
100 public char[][][] getMissingTypeNames() {
101 return missingTypeNames;
104 public char[] getEnclosingTypeName() {
105 return enclosingTypeName;
108 public int getModifiers() {
112 public char[] getGenericSignature() {
113 return genericSignature;
116 public char[] getEnclosingMethod() {
117 return enclosingMethod;
120 public char[][] getInterfaceNames() {
124 public boolean isAnonymous() {
128 public char[] sourceFileName() {
129 return sourceFileName;
132 public boolean isLocal() {
136 public boolean isMember() {
140 public char[] getSuperclassName() {
141 return superclassName;
144 public char[] getFileName() {
148 public char[] getName() {
152 public long getTagBits() {
156 public boolean isBinaryType() {
160 public IBinaryField[] getFields() {
164 public IBinaryMethod[] getMethods() {
168 public IBinaryNestedType[] getMemberTypes() {
172 public IBinaryAnnotation[] getAnnotations() {
176 public char[] getSourceName() {
180 public IBinaryTypeAnnotation[] getTypeAnnotations() {
181 return typeAnnotations;