You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CompactTypeStructureRepresentation.java 5.0KB

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