Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 19893 Details for
Bug 90344
Building JSR 175 annotation into binding and exposing them through DOM
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
First patch for this bug (in another setup)
jdtCorePatch.txt (text/plain), 207.77 KB, created by
Theodora Yeung
on 2005-04-13 23:29:14 EDT
(
hide
)
Description:
First patch for this bug (in another setup)
Filename:
MIME Type:
Creator:
Theodora Yeung
Created:
2005-04-13 23:29:14 EDT
Size:
207.77 KB
patch
obsolete
>Index: codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java,v >retrieving revision 1.108 >diff -u -r1.108 SelectionEngine.java >--- codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 30 Mar 2005 10:15:02 -0000 1.108 >+++ codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 14 Apr 2005 03:17:40 -0000 >@@ -889,7 +889,7 @@ > throw new SelectionNodeFound(constructorDeclaration.binding); > } else { > if (constructorDeclaration.scope != null) { >- throw new SelectionNodeFound(new MethodBinding(constructorDeclaration.modifiers, constructorDeclaration.selector, null, null, null, constructorDeclaration.scope.referenceType().binding)); >+ throw new SelectionNodeFound(new SourceMethodBinding(constructorDeclaration.modifiers, constructorDeclaration.selector, null, null, null, constructorDeclaration.scope.referenceType().binding)); > } > } > } >@@ -919,7 +919,14 @@ > throw new SelectionNodeFound(methodDeclaration.binding); > } else { > if (methodDeclaration.scope != null) { >- throw new SelectionNodeFound(new MethodBinding(methodDeclaration.modifiers, methodDeclaration.selector, null, null, null, methodDeclaration.scope.referenceType().binding)); >+ MethodBinding binding; >+ binding = new SourceMethodBinding(methodDeclaration.modifiers, >+ methodDeclaration.selector, >+ null, >+ null, >+ null, >+ methodDeclaration.scope.referenceType().binding); >+ throw new SelectionNodeFound(binding); > } > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v >retrieving revision 1.40 >diff -u -r1.40 ASTNode.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 22 Mar 2005 11:15:00 -0000 1.40 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 14 Apr 2005 03:17:47 -0000 >@@ -428,6 +428,7 @@ > for (int i = 0; i < length; i++) { > Annotation annotation = annotations[i]; > annotation.recipient = recipient; >+ annotation.compilerAnnotation = new SourceAnnotation(annotation); > annotationTypes[i] = annotation.resolveType(scope); > } > // check duplicate annotations >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java,v >retrieving revision 1.37 >diff -u -r1.37 Annotation.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 15 Mar 2005 10:43:16 -0000 1.37 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 14 Apr 2005 03:17:47 -0000 >@@ -21,9 +21,12 @@ > > final static MemberValuePair[] NoValuePairs = new MemberValuePair[0]; > public int declarationSourceEnd; >- public Binding recipient; >- >+ public Binding recipient; > public TypeReference type; >+ /** >+ * The representation of this annotation in the type system. >+ */ >+ public SourceAnnotation compilerAnnotation; > > public static long getRetentionPolicy(char[] policyName) { > if (policyName == null || policyName.length == 0) >@@ -297,8 +300,8 @@ > } > } > return this.resolvedType; >- } >- >+ } >+ > public abstract void traverse(ASTVisitor visitor, BlockScope scope); > public abstract void traverse(ASTVisitor visitor, CompilationUnitScope scope); > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java,v >retrieving revision 1.16 >diff -u -r1.16 ForeachStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 31 Mar 2005 13:21:07 -0000 1.16 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 14 Apr 2005 03:17:50 -0000 >@@ -23,6 +23,7 @@ > import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; > import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; >+import org.eclipse.jdt.internal.compiler.lookup.SourceMethodBinding; > import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; > >@@ -182,7 +183,7 @@ > // declaringClass.iterator(); > final TypeBinding collectionTypeBinding = collection.resolvedType.erasure(); > MethodBinding iteratorMethodBinding = >- new MethodBinding( >+ new SourceMethodBinding( > AccPublic, > "iterator".toCharArray(),//$NON-NLS-1$ > scope.getJavaUtilIterator(), >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java,v >retrieving revision 1.101 >diff -u -r1.101 TypeDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 20 Mar 2005 21:10:09 -0000 1.101 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 14 Apr 2005 03:17:55 -0000 >@@ -156,7 +156,7 @@ > } > > //============BINDING UPDATE========================== >- methodDeclaration.binding = new MethodBinding( >+ methodDeclaration.binding = new SourceMethodBinding( > methodDeclaration.modifiers, //methodDeclaration > methodBinding.selector, > methodBinding.returnType, >@@ -416,7 +416,7 @@ > } > > //============BINDING UPDATE========================== >- cd.binding = new MethodBinding( >+ cd.binding = new SourceMethodBinding( > cd.modifiers, //methodDeclaration > argumentsLength == 0 ? NoParameters : argumentTypes, //arguments bindings > inheritedConstructorBinding.thrownExceptions, //exceptions >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java,v >retrieving revision 1.62 >diff -u -r1.62 ClassFileReader.java >--- compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java 23 Feb 2005 02:47:58 -0000 1.62 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java 14 Apr 2005 03:17:56 -0000 >@@ -15,9 +15,7 @@ > import java.util.Arrays; > > import org.eclipse.jdt.core.compiler.CharOperation; >-import org.eclipse.jdt.internal.compiler.ast.Annotation; > import org.eclipse.jdt.internal.compiler.codegen.AttributeNamesConstants; >-import org.eclipse.jdt.internal.compiler.codegen.ConstantPool; > import org.eclipse.jdt.internal.compiler.env.*; > import org.eclipse.jdt.internal.compiler.impl.Constant; > import org.eclipse.jdt.internal.compiler.lookup.TagBits; >@@ -70,6 +68,7 @@ > private int constantPoolCount; > private int[] constantPoolOffsets; > private FieldInfo[] fields; >+ private AnnotationInfo[] annotations; > private int fieldsCount; > // initialized in case the .class file is a nested type > private InnerClassInfo innerInfo; >@@ -216,8 +215,12 @@ > if (this.methodsCount != 0) { > this.methods = new MethodInfo[this.methodsCount]; > MethodInfo method; >+ final boolean isAnnotationType = (this.accessFlags & AccAnnotation) != 0; > for (int i = 0; i < this.methodsCount; i++) { >- method = new MethodInfo(reference, this.constantPoolOffsets, readOffset); >+ if( isAnnotationType ) >+ method = new AnnotationMethodInfo(reference, this.constantPoolOffsets, readOffset); >+ else >+ method = new MethodInfo(reference, this.constantPoolOffsets, readOffset); > this.methods[i] = method; > readOffset += method.sizeInBytes(); > } >@@ -281,9 +284,12 @@ > } > } > break; >- case 'R' : >+ case 'R' : > if (CharOperation.equals(attributeName, RuntimeVisibleAnnotationsName)) { >- decodeStandardAnnotations(readOffset); >+ decodeAnnotations(readOffset, true); >+ } >+ else if(CharOperation.equals(attributeName, RuntimeInvisibleAnnotationsName )){ >+ decodeAnnotations(readOffset, false); > } > break; > } >@@ -294,10 +300,11 @@ > } > } catch(ClassFormatException e) { > throw e; >- } catch (Exception e) { >+ } catch (Exception e) { >+ e.printStackTrace(); > throw new ClassFormatException( > ClassFormatException.ErrTruncatedInput, >- readOffset); >+ readOffset); > } > } > >@@ -309,191 +316,33 @@ > public int accessFlags() { > return this.accessFlags; > } >-private int decodeAnnotation(int offset) { >- int readOffset = offset; >- int utf8Offset = this.constantPoolOffsets[u2At(offset)]; >- char[] typeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >- int numberOfPairs = u2At(offset + 2); >- readOffset += 4; >- switch(typeName.length) { >- case 21 : >- if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_INHERITED)) { >- this.tagBits |= TagBits.AnnotationInherited; >- return readOffset; >- } >- break; >- case 22 : >- if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_DEPRECATED)) { >- this.tagBits |= TagBits.AnnotationDeprecated; >- return readOffset; >- } >- break; >- case 29 : >- if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_TARGET)) { >- for (int i = 0; i < numberOfPairs; i++) { >- readOffset += 2; >- readOffset = decodeElementValueForJavaLangAnnotationTarget(readOffset); >- } >- return readOffset; >- } >- break; >- case 33 : >- if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_DOCUMENTED)) { >- this.tagBits |= TagBits.AnnotationDocumented; >- return readOffset; >- } >- break; >- case 32 : >- if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_RETENTION)) { >- for (int i = 0; i < numberOfPairs; i++) { >- readOffset += 2; >- readOffset = decodeElementValueForJavaLangAnnotationRetention(readOffset); >- } >- return readOffset; >- } >- break; >- } >- for (int i = 0; i < numberOfPairs; i++) { >- readOffset += 2; >- readOffset = decodeElementValue(readOffset); >- } >- return readOffset; >-} >-private int decodeElementValue(int offset) { >- int readOffset = offset; >- int tag = u1At(readOffset); >- readOffset++; >- switch(tag) { >- case 'B' : >- case 'C' : >- case 'D' : >- case 'F' : >- case 'I' : >- case 'J' : >- case 'S' : >- case 'Z' : >- case 's' : >- readOffset += 2; >- break; >- case 'e' : >- readOffset += 4; >- break; >- case 'c' : >- readOffset += 2; >- break; >- case '@' : >- readOffset = decodeAnnotation(readOffset); >- break; >- case '[' : >- int numberOfValues = u2At(readOffset); >- readOffset += 2; >- for (int i = 0; i < numberOfValues; i++) { >- readOffset = decodeElementValue(readOffset); >- } >- break; >- } >- return readOffset; >-} >-private int decodeElementValueForJavaLangAnnotationTarget(int offset) { >- int readOffset = offset; >- int tag = u1At(readOffset); >- readOffset++; >- switch(tag) { >- case 'B' : >- case 'C' : >- case 'D' : >- case 'F' : >- case 'I' : >- case 'J' : >- case 'S' : >- case 'Z' : >- case 's' : >- readOffset += 2; >- break; >- case 'e' : >- int utf8Offset = this.constantPoolOffsets[u2At(readOffset)]; >- char[] typeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >- readOffset += 2; >- utf8Offset = this.constantPoolOffsets[u2At(readOffset)]; >- char[] constName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >- readOffset += 2; >- if (typeName.length == 34 && CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_ELEMENTTYPE)) { >- this.tagBits |= Annotation.getTargetElementType(constName); >- } >- break; >- case 'c' : >- readOffset += 2; >- break; >- case '@' : >- readOffset = decodeAnnotation(readOffset); >- break; >- case '[' : >- int numberOfValues = u2At(readOffset); >- readOffset += 2; >- if (numberOfValues == 0) { >- this.tagBits |= TagBits.AnnotationTarget; >- } else { >- for (int i = 0; i < numberOfValues; i++) { >- readOffset = decodeElementValueForJavaLangAnnotationTarget(readOffset); >- } >- } >- break; >- } >- return readOffset; >-} >-private int decodeElementValueForJavaLangAnnotationRetention(int offset) { >- int readOffset = offset; >- int tag = u1At(readOffset); >- readOffset++; >- switch(tag) { >- case 'B' : >- case 'C' : >- case 'D' : >- case 'F' : >- case 'I' : >- case 'J' : >- case 'S' : >- case 'Z' : >- case 's' : >- readOffset += 2; >- break; >- case 'e' : >- int utf8Offset = this.constantPoolOffsets[u2At(readOffset)]; >- char[] typeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >- readOffset += 2; >- utf8Offset = this.constantPoolOffsets[u2At(readOffset)]; >- char[] constName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >- readOffset += 2; >- this.tagBits |= Annotation.getRetentionPolicy(constName); >- if (typeName.length == 38 && CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_RETENTIONPOLICY)) { >- this.tagBits |= Annotation.getRetentionPolicy(constName); >- } >- break; >- case 'c' : >- readOffset += 2; >- break; >- case '@' : >- readOffset = decodeAnnotation(readOffset); >- break; >- case '[' : >- int numberOfValues = u2At(readOffset); >- readOffset += 2; >- for (int i = 0; i < numberOfValues; i++) { >- readOffset = decodeElementValue(readOffset); // retention policy cannot be in an array initializer >- } >- break; >- } >- return readOffset; >-} >+ > /** >- * @param offset the offset is located at the beginning of the runtime visible >+ * @param offset the offset is located at the beginning of the > * annotation attribute. > */ >-private void decodeStandardAnnotations(int offset) { >+private void decodeAnnotations(int offset, boolean runtimeVisible) { > int numberOfAnnotations = u2At(offset + 6); > int readOffset = offset + 8; >- for (int i = 0; i < numberOfAnnotations; i++) { >- readOffset = decodeAnnotation(readOffset); >+ int index = 0; >+ if( numberOfAnnotations > 0 ){ >+ if( this.annotations == null ) >+ this.annotations = new AnnotationInfo[numberOfAnnotations]; >+ else{ >+ index = this.annotations.length; >+ int newTotal = this.annotations.length + numberOfAnnotations; >+ final AnnotationInfo[] newAnnos = new AnnotationInfo[newTotal]; >+ System.arraycopy(this.annotations, 0, newAnnos, 0, this.annotations.length); >+ this.annotations = newAnnos; >+ } >+ } >+ for (int i = 0; i < numberOfAnnotations; i++, index++) { >+ this.annotations[index] = new AnnotationInfo(reference, >+ readOffset, >+ this.constantPoolOffsets, >+ runtimeVisible, false); >+ readOffset = this.annotations[index].getLength() + readOffset; >+ this.tagBits |= this.annotations[index].getStandardAnnotationTagBits(); > } > } > /** >@@ -655,6 +504,13 @@ > public IBinaryMethod[] getMethods() { > return this.methods; > } >+ >+/** >+ * @return the annotations or null if there is none. >+ */ >+public IBinaryAnnotation[] getAnnotations(){ >+ return this.annotations; >+} > /** > * Answer an int whose bits are set according the access constants > * defined by the VM spec. >@@ -967,14 +823,20 @@ > } > for (int i = 0, max = methodsCount; i < max; i++) { > methods[i].initialize(); >- } >+ } > if (innerInfos != null) { > for (int i = 0, max = innerInfos.length; i < max; i++) { > innerInfos[i].initialize(); > } > } >+ if(annotations != null){ >+ for( int i=0, max = annotations.length; i < max; i++ ){ >+ annotations[i].initialize(); >+ } >+ } > this.reset(); >- } catch(RuntimeException e) { >+ } catch(RuntimeException e) { >+ e.printStackTrace(); > ClassFormatException exception = new ClassFormatException(e, this.classFileName); > throw exception; > } >@@ -1050,4 +912,61 @@ > print.flush(); > return out.toString(); > } >+ >+public static void main(String[] args) >+ throws ClassFormatException, IOException >+{ >+ if( args == null || args.length != 1 ){ >+ System.err.println("ClassFileReader <filename>"); //$NON-NLS-1$ >+ System.exit(1); >+ } >+ File file = new File(args[0]); >+ >+ final ClassFileReader reader = read(file, true); >+ >+ if(reader.annotations != null){ >+ System.err.println(); >+ for( int i=0; i<reader.annotations.length; i++ ){ >+ System.err.println(reader.annotations[i]); >+ } >+ } >+ >+ System.err.print("class "); //$NON-NLS-1$ >+ System.err.print( reader.getName() ); >+ final char[] superclass = reader.getSuperclassName(); >+ if( superclass != null){ >+ System.err.print( " extends " ); //$NON-NLS-1$ >+ System.err.print(superclass); >+ } >+ System.err.println(); >+ final char[][] interfaces = reader.getInterfaceNames(); >+ if( interfaces != null && interfaces.length > 0 ){ >+ >+ System.err.print(" implements "); //$NON-NLS-1$ >+ for( int i=0; i<interfaces.length; i++ ){ >+ if( i != 0 ) >+ System.err.print(", " ); //$NON-NLS-1$ >+ System.err.println(interfaces[i]); >+ } >+ } >+ System.err.println(); >+ System.err.println('{'); >+ >+ if( reader.fields != null ){ >+ for( int i=0; i<reader.fields.length; i++ ){ >+ System.err.println(reader.fields[i]); >+ System.err.println(); >+ } >+ } >+ >+ if( reader.methods != null ){ >+ for( int i=0; i<reader.methods.length; i++ ){ >+ System.err.println(reader.methods[i]); >+ System.err.println(); >+ } >+ } >+ System.err.println(); >+ System.err.println('}'); >+} >+ > } >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java,v >retrieving revision 1.23 >diff -u -r1.23 ClassFileStruct.java >--- compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java 23 Feb 2005 02:47:58 -0000 1.23 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java 14 Apr 2005 03:17:56 -0000 >@@ -163,6 +163,7 @@ > } > return outputBuf; > } >+ > public static void verifyMethodNameAndSignature(char[] name, char[] signature) throws ClassFormatException { > > // ensure name is not empty >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java,v >retrieving revision 1.36 >diff -u -r1.36 FieldInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java 23 Feb 2005 02:47:58 -0000 1.36 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java 14 Apr 2005 03:17:56 -0000 >@@ -12,7 +12,7 @@ > > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.codegen.AttributeNamesConstants; >-import org.eclipse.jdt.internal.compiler.codegen.ConstantPool; >+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation; > import org.eclipse.jdt.internal.compiler.env.IBinaryField; > import org.eclipse.jdt.internal.compiler.impl.BooleanConstant; > import org.eclipse.jdt.internal.compiler.impl.ByteConstant; >@@ -24,7 +24,6 @@ > import org.eclipse.jdt.internal.compiler.impl.LongConstant; > import org.eclipse.jdt.internal.compiler.impl.ShortConstant; > import org.eclipse.jdt.internal.compiler.impl.StringConstant; >-import org.eclipse.jdt.internal.compiler.lookup.TagBits; > import org.eclipse.jdt.internal.compiler.lookup.TypeIds; > import org.eclipse.jdt.internal.compiler.util.Util; > >@@ -39,6 +38,7 @@ > private int signatureUtf8Offset; > private long tagBits; > private Object wrappedConstantValue; >+ private AnnotationInfo[] annotations; > /** > * @param classFileBytes byte[] > * @param offsets int[] >@@ -64,7 +64,10 @@ > break; > case 'R' : > if (CharOperation.equals(attributeName, RuntimeVisibleAnnotationsName)) { >- decodeStandardAnnotations(readOffset); >+ decodeAnnotations(readOffset, true); >+ } >+ else if(CharOperation.equals(attributeName, RuntimeInvisibleAnnotationsName)) { >+ decodeAnnotations(readOffset, false); > } > } > } >@@ -79,66 +82,40 @@ > } > return new String(this.getName()).compareTo(new String(((FieldInfo) o).getName())); > } >-private int decodeAnnotation(int offset) { >- int readOffset = offset; >- int utf8Offset = this.constantPoolOffsets[u2At(offset)] - structOffset; >- char[] typeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >- int numberOfPairs = u2At(offset + 2); >- readOffset += 4; >- if (typeName.length == 22 && CharOperation.equals(typeName, ConstantPool.JAVA_LANG_DEPRECATED)) { >- this.tagBits |= TagBits.AnnotationDeprecated; >- return readOffset; >- } >- for (int i = 0; i < numberOfPairs; i++) { >- readOffset += 2; >- readOffset = decodeElementValue(readOffset); >- } >- return readOffset; >-} >-private int decodeElementValue(int offset) { >- int readOffset = offset; >- int tag = u1At(readOffset); >- readOffset++; >- switch(tag) { >- case 'B' : >- case 'C' : >- case 'D' : >- case 'F' : >- case 'I' : >- case 'J' : >- case 'S' : >- case 'Z' : >- case 's' : >- readOffset += 2; >- break; >- case 'e' : >- readOffset += 4; >- break; >- case 'c' : >- readOffset += 2; >- break; >- case '@' : >- readOffset += decodeAnnotation(readOffset); >- break; >- case '[' : >- int numberOfValues = u2At(readOffset); >- readOffset += 2; >- for (int i = 0; i < numberOfValues; i++) { >- readOffset = decodeElementValue(readOffset); >- } >- break; >- } >- return readOffset; >-} >+ > /** >- * @param offset the offset is located at the beginning of the runtime visible >+ * @param offset the offset is located at the beginning of the > * annotation attribute. > */ >-private void decodeStandardAnnotations(int offset) { >+private void decodeAnnotations(int offset, boolean runtimeVisible) { >+/* >+int actualOffset = offset + structOffset; >+String text = runtimeVisible ? " runtime visible " : " runtime invisible "; >+System.err.println("decoding field_info" + text + "annotation at " + actualOffset); >+*/ > int numberOfAnnotations = u2At(offset + 6); > int readOffset = offset + 8; >- for (int i = 0; i < numberOfAnnotations; i++) { >- readOffset = decodeAnnotation(readOffset); >+ int index=0; >+ if( numberOfAnnotations > 0 ){ >+ if( this.annotations == null ) >+ this.annotations = new AnnotationInfo[numberOfAnnotations]; >+ else{ >+ int curlen = this.annotations.length; >+ index = curlen; >+ int newTotal = curlen + numberOfAnnotations; >+ final AnnotationInfo[] newAnnos = new AnnotationInfo[newTotal]; >+ System.arraycopy(this.annotations, 0, newAnnos, 0, curlen); >+ this.annotations = newAnnos; >+ } >+ } >+ for (int i = 0; i < numberOfAnnotations; i++, index++) { >+ this.annotations[index] = new AnnotationInfo(reference, >+ readOffset + structOffset, >+ this.constantPoolOffsets, >+ runtimeVisible, >+ false); >+ readOffset = this.annotations[index].getLength() + readOffset; >+ this.tagBits |= this.annotations[index].getStandardAnnotationTagBits(); > } > } > /** >@@ -211,6 +188,14 @@ > } > return descriptor; > } >+ >+/** >+ * @return the annotations or null if there is none. >+ */ >+public IBinaryAnnotation[] getAnnotations(){ >+ return this.annotations; >+} >+ > /** > * Return a wrapper that contains the constant of the field. > * @return java.lang.Object >@@ -269,6 +254,11 @@ > getConstant(); > getTypeName(); > getGenericSignature(); >+ if( annotations != null ){ >+ for( int i=0, max = annotations.length; i<max; i++ ){ >+ annotations[i].initialize(); >+ } >+ } > reset(); > } > /** >@@ -365,6 +355,11 @@ > } > protected void reset() { > this.constantPoolOffsets = null; >+ if( annotations != null ){ >+ for( int i=0, max = annotations.length; i<max; i++ ){ >+ annotations[i].reset(); >+ } >+ } > super.reset(); > } > /** >@@ -380,6 +375,15 @@ > } > public String toString() { > StringBuffer buffer = new StringBuffer(this.getClass().getName()); >+ >+ if(this.annotations != null){ >+ buffer.append('\n'); >+ for( int i=0; i<this.annotations.length; i++ ){ >+ buffer.append(annotations[i]); >+ buffer.append('\n'); >+ } >+ } >+ > int modifiers = getModifiers(); > return buffer > .append("{") //$NON-NLS-1$ >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java,v >retrieving revision 1.35 >diff -u -r1.35 MethodInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java 23 Feb 2005 02:47:58 -0000 1.35 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java 14 Apr 2005 03:17:56 -0000 >@@ -12,21 +12,29 @@ > > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.codegen.AttributeNamesConstants; >-import org.eclipse.jdt.internal.compiler.codegen.ConstantPool; >+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation; > import org.eclipse.jdt.internal.compiler.env.IBinaryMethod; >-import org.eclipse.jdt.internal.compiler.lookup.TagBits; > > public class MethodInfo extends ClassFileStruct implements IBinaryMethod, AttributeNamesConstants, Comparable { > static private final char[][] noException = CharOperation.NO_CHAR_CHAR; > private int accessFlags; > private int attributeBytes; >- private int[] constantPoolOffsets; >+ protected int[] constantPoolOffsets; > private char[] descriptor; > private char[][] exceptionNames; > private char[] name; > private char[] signature; > private int signatureUtf8Offset; >- private long tagBits; >+ private long tagBits; >+ /** method annotation as well as parameter annotations >+ * index 0 always contains the method annotation info. >+ * index 1 and onwards contains parameter annotation info. >+ * If the array is of size 0, there are no annotations. >+ * If the array is of size 1, there are only method annotations. >+ * if the array has a size greater than 1, then there are at least >+ * parameter annotations. >+ */ >+ private AnnotationInfo[][] allAnnotations; > > /** > * @param classFileBytes byte[] >@@ -45,7 +53,7 @@ > int utf8Offset = constantPoolOffsets[u2At(readOffset)] - structOffset; > char[] attributeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); > if (attributeName.length > 0) { >- switch(attributeName[0]) { >+ switch(attributeName[0]) { > case 'S' : > if (CharOperation.equals(AttributeNamesConstants.SignatureName, attributeName)) { > this.signatureUtf8Offset = constantPoolOffsets[u2At(readOffset + 6)] - structOffset; >@@ -53,7 +61,16 @@ > break; > case 'R' : > if (CharOperation.equals(attributeName, RuntimeVisibleAnnotationsName)) { >- decodeStandardAnnotations(readOffset); >+ decodeMethodAnnotations(readOffset, true); >+ } >+ else if (CharOperation.equals(attributeName, RuntimeInvisibleAnnotationsName)) { >+ decodeMethodAnnotations(readOffset, false); >+ } >+ else if( CharOperation.equals(attributeName, RuntimeVisibleParameterAnnotationsName)){ >+ decodeParamAnnotations(readOffset, true); >+ } >+ else if( CharOperation.equals(attributeName, RuntimeInvisibleParameterAnnotationsName)){ >+ decodeParamAnnotations(readOffset, false); > } > } > } >@@ -71,68 +88,128 @@ > if (result != 0) return result; > return new String(this.getMethodDescriptor()).compareTo(new String(otherMethod.getMethodDescriptor())); > } >-private int decodeAnnotation(int offset) { >- int readOffset = offset; >- int utf8Offset = this.constantPoolOffsets[u2At(offset)] - structOffset; >- char[] typeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >- int numberOfPairs = u2At(offset + 2); >- readOffset += 4; >- if (typeName.length == 22 && CharOperation.equals(typeName, ConstantPool.JAVA_LANG_DEPRECATED)) { >- this.tagBits |= TagBits.AnnotationDeprecated; >- return readOffset; >- } >- for (int i = 0; i < numberOfPairs; i++) { >- readOffset += 2; >- readOffset = decodeElementValue(readOffset); >+ >+/** >+ * @param offset the offset is located at the beginning of the >+ * parameter annotation attribute. >+ */ >+private void decodeParamAnnotations(int offset, boolean runtimeVisible) >+{ >+ // u1 num_parameters; >+ int numberOfParameters = u1At(offset + 6); >+ if( numberOfParameters > 0 ){ >+ // u2 attribute_name_index + u4 attribute_length + u1 num_parameters >+ int readOffset = offset + 7; >+ for( int i=0; i<numberOfParameters; i++ ){ >+ int numberOfAnnotations = u2At(readOffset); >+ readOffset += 2; >+ if( numberOfAnnotations > 0 ){ >+ if(this.allAnnotations == null){ >+ this.allAnnotations = new AnnotationInfo[numberOfParameters + 1][]; >+ for(int j=0, len = numberOfParameters + 1; j < len; j++){ >+ this.allAnnotations[j] = null; >+ } >+ } >+ else{ >+ if( this.allAnnotations.length == 1 ){ >+ // make room for the parameter annotations >+ final AnnotationInfo[][] newArray = new AnnotationInfo[numberOfParameters + 1][]; >+ newArray[0] = this.allAnnotations[0]; >+ this.allAnnotations = newArray; >+ for(int j=1; j <= numberOfParameters; j++){ >+ this.allAnnotations[j] = null; >+ } >+ } >+ // else >+ // have already initialize the field to the proper size. >+ } >+ final AnnotationInfo[] annos = >+ decodeAnnotations(readOffset, runtimeVisible, numberOfAnnotations); >+ for( int aIndex = 0; aIndex < annos.length; aIndex ++ ) >+ readOffset += annos[aIndex].getLength(); >+ final int paramAnnoIndex = i + 1; >+ if( this.allAnnotations[paramAnnoIndex] == null ) >+ this.allAnnotations[paramAnnoIndex] = annos; >+ else{ >+ final int curlen = this.allAnnotations[paramAnnoIndex].length; >+ final int newTotal = curlen + numberOfAnnotations; >+ final AnnotationInfo[] newAnnos = new AnnotationInfo[newTotal]; >+ System.arraycopy(this.allAnnotations[paramAnnoIndex], 0, newAnnos, 0, curlen); >+ System.arraycopy(annos, 0, newAnnos, curlen, numberOfAnnotations); >+ this.allAnnotations[paramAnnoIndex] = newAnnos; >+ } >+ } >+ } > } >- return readOffset; > } >-private int decodeElementValue(int offset) { >- int readOffset = offset; >- int tag = u1At(readOffset); >- readOffset++; >- switch(tag) { >- case 'B' : >- case 'C' : >- case 'D' : >- case 'F' : >- case 'I' : >- case 'J' : >- case 'S' : >- case 'Z' : >- case 's' : >- readOffset += 2; >- break; >- case 'e' : >- readOffset += 4; >- break; >- case 'c' : >- readOffset += 2; >- break; >- case '@' : >- readOffset += decodeAnnotation(readOffset); >- break; >- case '[' : >- int numberOfValues = u2At(readOffset); >- readOffset += 2; >- for (int i = 0; i < numberOfValues; i++) { >- readOffset = decodeElementValue(readOffset); >+ >+/** >+ * @param offset begining of the 'RuntimeVisibleAnnotation' or 'RuntimeInvisibleAnnotation' >+ * attribute. >+ * @param runtimeVisible <code>true</code> to indicate decoding 'RuntimeVisibleAnnotation' >+ */ >+private void decodeMethodAnnotations(int offset, boolean runtimeVisible){ >+ int numberOfAnnotations = u2At(offset + 6); >+ final AnnotationInfo[] annos = decodeAnnotations(offset + 8, runtimeVisible, numberOfAnnotations); >+ >+ if( numberOfAnnotations > 0 ){ >+ if( runtimeVisible ){ >+ for( int i=0; i<numberOfAnnotations; i++ ){ >+ this.tagBits |= annos[i].getStandardAnnotationTagBits(); > } >- break; >+ } >+ >+ if( this.allAnnotations == null ) >+ this.allAnnotations = new AnnotationInfo[][]{annos}; >+ else{ >+ int curlen = this.allAnnotations[0].length; >+ int newTotal = curlen + numberOfAnnotations; >+ final AnnotationInfo[] newAnnos = new AnnotationInfo[newTotal]; >+ System.arraycopy(this.allAnnotations[0], 0, newAnnos, 0, curlen); >+ System.arraycopy(annos, 0, newAnnos, curlen, numberOfAnnotations); >+ this.allAnnotations[0] = newAnnos; >+ } > } >- return readOffset; > } >+ > /** >- * @param offset the offset is located at the beginning of the runtime visible >+ * @param offset the offset is located at the beginning of the > * annotation attribute. > */ >-private void decodeStandardAnnotations(int offset) { >- int numberOfAnnotations = u2At(offset + 6); >- int readOffset = offset + 8; >+private AnnotationInfo[] decodeAnnotations(int offset, >+ boolean runtimeVisible, >+ int numberOfAnnotations) { >+ int readOffset = offset; >+ AnnotationInfo[] result = null; >+ if( numberOfAnnotations > 0 ){ >+ result = new AnnotationInfo[numberOfAnnotations]; >+ } >+ > for (int i = 0; i < numberOfAnnotations; i++) { >- readOffset = decodeAnnotation(readOffset); >+ result[i] = new AnnotationInfo(reference, >+ readOffset + structOffset, >+ this.constantPoolOffsets, >+ runtimeVisible, >+ false); >+ readOffset = result[i].getLength() + readOffset; > } >+ return result; > } >+ >+/** >+ * @return the annotations or null if there is none. >+ */ >+public IBinaryAnnotation[] getAnnotations(){ >+ if( this.allAnnotations == null || this.allAnnotations.length == 0 ) return null; >+ return this.allAnnotations[0]; >+} >+ >+public IBinaryAnnotation[] getParameterAnnotations(int index) >+{ >+ if(this.allAnnotations == null || this.allAnnotations.length < 2 ) return null; >+ return this.allAnnotations[index + 1]; >+} >+ > /** > * @see org.eclipse.jdt.internal.compiler.env.IGenericMethod#getArgumentNames() > */ >@@ -221,6 +298,16 @@ > getMethodDescriptor(); > getExceptionTypeNames(); > getGenericSignature(); >+ if( this.allAnnotations != null ){ >+ for( int i=0, max = this.allAnnotations.length; i<max; i++ ){ >+ if( this.allAnnotations[i] != null ){ >+ for( int aIndex=0, aMax = this.allAnnotations[i].length; aIndex<aMax; aIndex++ ){ >+ final AnnotationInfo anno = this.allAnnotations[i][aIndex]; >+ anno.initialize(); >+ } >+ } >+ } >+ } > reset(); > } > /** >@@ -306,6 +393,17 @@ > } > protected void reset() { > this.constantPoolOffsets = null; >+ if( this.allAnnotations != null ){ >+ for( int i=0, max = this.allAnnotations.length; i<max; i++ ){ >+ if( this.allAnnotations[i] != null ){ >+ final int aMax = this.allAnnotations[i].length; >+ for( int aIndex=0; aIndex<aMax; aIndex++ ){ >+ final AnnotationInfo anno = this.allAnnotations[i][aIndex]; >+ anno.reset(); >+ } >+ } >+ } >+ } > super.reset(); > } > /** >@@ -316,13 +414,45 @@ > public int sizeInBytes() { > return attributeBytes; > } >-public String toString() { >+ >+public Object getDefaultValue(){ return null; } >+ >+void toString(StringBuilder buffer) >+{ > int modifiers = getModifiers(); > char[] desc = getGenericSignature(); > if (desc == null) > desc = getMethodDescriptor(); >- StringBuffer buffer = new StringBuffer(this.getClass().getName()); >- return buffer >+ >+ buffer.append(this.getClass().getName()); >+ >+ final int totalNumAnno = this.allAnnotations == null ? 0 : this.allAnnotations.length; >+ if(totalNumAnno > 0){ >+ buffer.append('\n'); >+ if(this.allAnnotations[0] != null ){ >+ for( int i=0, len = this.allAnnotations[0].length; i<len; i++ ){ >+ >+ buffer.append(this.allAnnotations[0][i]); >+ buffer.append('\n'); >+ } >+ } >+ } >+ >+ if(totalNumAnno > 1){ >+ buffer.append('\n'); >+ for( int i=1; i<totalNumAnno; i++ ){ >+ buffer.append("param" + (i-1)); //$NON-NLS-1$ >+ buffer.append('\n'); >+ if( this.allAnnotations[i] != null ){ >+ for( int j=0, numParamAnno=this.allAnnotations[i].length; j<numParamAnno; j++){ >+ buffer.append(this.allAnnotations[i][j]); >+ buffer.append('\n'); >+ } >+ } >+ } >+ } >+ >+ buffer > .append("{") //$NON-NLS-1$ > .append( > ((modifiers & AccDeprecated) != 0 ? "deprecated " : "") //$NON-NLS-1$ //$NON-NLS-2$ >@@ -335,7 +465,11 @@ > + ((modifiers & 0x0080) == 0x0080 ? "varargs " : "")) //$NON-NLS-1$ //$NON-NLS-2$ > .append(getSelector()) > .append(desc) >- .append("}") //$NON-NLS-1$ >- .toString(); >+ .append("}"); //$NON-NLS-1$ >+} >+public String toString() { >+ final StringBuilder buffer = new StringBuilder(); >+ toString(buffer); >+ return buffer.toString(); > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/env/IBinaryField.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryField.java,v >retrieving revision 1.10 >diff -u -r1.10 IBinaryField.java >--- compiler/org/eclipse/jdt/internal/compiler/env/IBinaryField.java 25 Mar 2005 11:10:02 -0000 1.10 >+++ compiler/org/eclipse/jdt/internal/compiler/env/IBinaryField.java 14 Apr 2005 03:17:59 -0000 >@@ -13,6 +13,12 @@ > import org.eclipse.jdt.internal.compiler.impl.Constant; > > public interface IBinaryField extends IGenericField { >+ >+/** >+ * @return the both runtime visible and invisible annoations that annotated this field. >+ */ >+IBinaryAnnotation[] getAnnotations(); >+ > /** > * > * @return org.eclipse.jdt.internal.compiler.Constant >Index: compiler/org/eclipse/jdt/internal/compiler/env/IBinaryMethod.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryMethod.java,v >retrieving revision 1.12 >diff -u -r1.12 IBinaryMethod.java >--- compiler/org/eclipse/jdt/internal/compiler/env/IBinaryMethod.java 18 Mar 2005 09:46:58 -0000 1.12 >+++ compiler/org/eclipse/jdt/internal/compiler/env/IBinaryMethod.java 14 Apr 2005 03:17:59 -0000 >@@ -16,7 +16,18 @@ > // member type) is also ignored by the compiler, BUT in this case it must be included > // in the constructor's signature. > >-public interface IBinaryMethod extends IGenericMethod { >+public interface IBinaryMethod extends IGenericMethod, IBinaryAnnotationMethod { >+ >+/** >+ * @return the both runtime visible and invisible annoations that annotated this method. >+ */ >+IBinaryAnnotation[] getAnnotations(); >+ >+/** >+ * @param index the index of the parameter of interest >+ * @return the annotations on the <code>index</code>th parameter or null if none exists. >+ */ >+IBinaryAnnotation[] getParameterAnnotations(int index); > > /** > * Answer the resolved names of the exception types in the >Index: compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java,v >retrieving revision 1.23 >diff -u -r1.23 IBinaryType.java >--- compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java 23 Feb 2005 02:47:58 -0000 1.23 >+++ compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java 14 Apr 2005 03:17:59 -0000 >@@ -57,6 +57,12 @@ > */ > > IBinaryMethod[] getMethods(); >+ >+/** >+ * @return the both runtime visible and invisible annoations that annotated this type. >+ */ >+IBinaryAnnotation[] getAnnotations(); >+ > /** > * Answer the resolved name of the type in the > * class file format as specified in section 4.2 of the Java 2 VM spec. >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java,v >retrieving revision 1.37 >diff -u -r1.37 ArrayBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java 23 Feb 2005 02:47:30 -0000 1.37 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java 14 Apr 2005 03:18:02 -0000 >@@ -17,7 +17,7 @@ > public final class ArrayBinding extends TypeBinding { > // creation and initialization of the length field > // the declaringClass of this field is intentionally set to null so it can be distinguished. >- public static final FieldBinding ArrayLength = new FieldBinding(LENGTH, IntBinding, AccPublic | AccFinal, null, Constant.NotAConstant); >+ public static final FieldBinding ArrayLength = new SourceFieldBinding(LENGTH, IntBinding, AccPublic | AccFinal, null, Constant.NotAConstant); > > public TypeBinding leafComponentType; > public int dimensions; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java,v >retrieving revision 1.72 >diff -u -r1.72 BinaryTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 15 Mar 2005 16:37:47 -0000 1.72 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 14 Apr 2005 03:18:02 -0000 >@@ -14,11 +14,16 @@ > > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation; >+import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair; > import org.eclipse.jdt.internal.compiler.env.IBinaryField; > import org.eclipse.jdt.internal.compiler.env.IBinaryMethod; > import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType; > import org.eclipse.jdt.internal.compiler.env.IBinaryType; >+import org.eclipse.jdt.internal.compiler.env.IClassReference; >+import org.eclipse.jdt.internal.compiler.env.IEnumConstantReference; > import org.eclipse.jdt.internal.compiler.env.IGenericType; >+import org.eclipse.jdt.internal.compiler.impl.Constant; > import org.eclipse.jdt.internal.compiler.problem.AbortCompilation; > > /* >@@ -42,6 +47,7 @@ > private MethodBinding[] methods; > private ReferenceBinding[] memberTypes; > protected TypeVariableBinding[] typeVariables; >+private AnnotationInstance[] annotations; > > // For the link with the principle structure > private LookupEnvironment environment; >@@ -172,6 +178,9 @@ > System.arraycopy(availableMethods, 0, availableMethods = new MethodBinding[count], 0, count); > return availableMethods; > } >+ >+public AnnotationInstance[] getAnnotations(){ return this.annotations; } >+ > void cachePartsFrom(IBinaryType binaryType, boolean needFieldsAndMethods) { > // default initialization for super-interfaces early, in case some aborting compilation error occurs, > // and still want to use binaries passed that point (e.g. type hierarchy resolver, see bug 63748). >@@ -266,7 +275,81 @@ > this.fields = NoFields; > this.methods = NoMethods; > } >+ this.annotations = createAnnotations(binaryType.getAnnotations()); >+} >+ >+private AnnotationInstance[] createAnnotations(IBinaryAnnotation[] annotationInfos ){ >+ >+ AnnotationInstance[] result = NoAnnotations; >+ if( annotationInfos != null ){ >+ int size = annotationInfos.length; >+ if( size > 0 ){ >+ result = new BinaryAnnotation[size]; >+ for( int i = 0; i < size; i++ ){ >+ result[i] = createAnnotation(annotationInfos[i]); >+ } >+ } >+ } >+ return result; >+} >+ >+private BinaryAnnotation createAnnotation(IBinaryAnnotation annnotationInfo ) >+{ >+ final ReferenceBinding annotationType = >+ environment.getTypeFromConstantPoolName(annnotationInfo.getTypeName(), 0, -1, false); >+ final BinaryAnnotation annotation = new BinaryAnnotation(annotationType, this.environment); >+ createElementValuePairs(annnotationInfo.getMemberValuePairs(), annotation); >+ return annotation; >+} >+ >+private void createElementValuePairs(final IBinaryElementValuePair[] pairs, >+ final BinaryAnnotation anno) >+{ >+ final int len = pairs == null ? 0 : pairs.length; >+ anno.pairs = NoElementValuePairs; >+ if( len > 1 ){ >+ anno.pairs = new ElementValuePair[len]; >+ for( int i = 0; i < len; i++ ){ >+ anno.pairs[i] = new BinaryElementValuePair(anno, >+ pairs[i].getMemberName(), >+ getMemberValue(pairs[i].getMemberValue())); >+ } >+ } > } >+ >+private Object getMemberValue(final Object binaryValue) >+{ >+ if( binaryValue == null ) return null; >+ if( binaryValue instanceof Constant ) >+ return binaryValue; >+ >+ else if( binaryValue instanceof IClassReference ){ >+ final IClassReference ref = (IClassReference)binaryValue; >+ return environment.getTypeFromSignature(ref.getTypeName(), 0, -1, false, null); >+ } >+ >+ else if( binaryValue instanceof IEnumConstantReference ){ >+ final IEnumConstantReference ref = (IEnumConstantReference)binaryValue; >+ final ReferenceBinding enumType = environment.getTypeFromConstantPoolName(ref.getTypeName(), 0, -1, false); >+ return enumType.getField(ref.getEnumConstantName(), false); >+ } >+ else if( binaryValue instanceof Object[] ){ >+ final Object[] objects = (Object[])binaryValue; >+ final int len = objects.length; >+ if( len == 0 ) return objects; >+ final Object[] values = new Object[len]; >+ for( int i = 0; i < len; i++ ){ >+ values[i] = getMemberValue(objects[i]); >+ } >+ return values; >+ } >+ else if( binaryValue instanceof IBinaryAnnotation ) >+ return createAnnotation((IBinaryAnnotation)binaryValue); >+ >+ // should never reach here. >+ throw new IllegalStateException(); >+} >+ > private void createFields(IBinaryField[] iFields, long sourceLevel) { > this.fields = NoFields; > if (iFields != null) { >@@ -281,13 +364,15 @@ > TypeBinding type = fieldSignature == null > ? environment.getTypeFromSignature(binaryField.getTypeName(), 0, -1, false, this) > : environment.getTypeFromTypeSignature(new SignatureWrapper(fieldSignature), NoTypeVariables, this); >+ AnnotationInstance[] fieldAnnos = createAnnotations(binaryField.getAnnotations()); > FieldBinding field = >- new FieldBinding( >+ new BinaryFieldBinding( > binaryField.getName(), > type, > binaryField.getModifiers() | AccUnresolved, > this, >- binaryField.getConstant()); >+ binaryField.getConstant(), >+ fieldAnnos); > field.id = i; // ordinal > if (use15specifics) > field.tagBits |= binaryField.getTagBits(); >@@ -304,6 +389,7 @@ > methodModifiers &= ~AccVarargs; // vararg methods are not recognized until 1.5 > ReferenceBinding[] exceptions = NoExceptions; > TypeBinding[] parameters = NoParameters; >+ AnnotationInstance[][] paramAnnotations = NoParamAnnotations; > TypeVariableBinding[] typeVars = NoTypeVariables; > TypeBinding returnType = null; > >@@ -327,6 +413,7 @@ > int size = numOfParams - startIndex; > if (size > 0) { > parameters = new TypeBinding[size]; >+ paramAnnotations = new AnnotationInstance[size][]; > index = 1; > int end = 0; // first character is always '(' so skip it > for (int i = 0; i < numOfParams; i++) { >@@ -334,8 +421,12 @@ > if (nextChar == 'L') > while ((nextChar = methodDescriptor[++end]) != ';'){/*empty*/} > >- if (i >= startIndex) // skip the synthetic arg if necessary >+ if (i >= startIndex){ // skip the synthetic arg if necessary > parameters[i - startIndex] = environment.getTypeFromSignature(methodDescriptor, index, end, false, this); >+ // 'paramAnnotations' line up with 'parameters' >+ // int parameter to method.getParameterAnnotations() include the synthetic arg. >+ paramAnnotations[i - startIndex] = createAnnotations(method.getParameterAnnotations(i)); >+ } > index = end + 1; > } > } >@@ -372,8 +463,14 @@ > while (wrapper.signature[wrapper.start] != ')') > types.add(environment.getTypeFromTypeSignature(wrapper, typeVars, this)); > wrapper.start++; // skip ')' >- parameters = new TypeBinding[types.size()]; >- types.toArray(parameters); >+ int numParam = types.size(); >+ parameters = new TypeBinding[numParam]; >+ types.toArray(parameters); >+ >+ paramAnnotations = new AnnotationInstance[numParam][]; >+ for( int i = 0; i < numParam; i ++ ){ >+ paramAnnotations[i] = createAnnotations( method.getParameterAnnotations(i) ); >+ } > } > } > >@@ -401,10 +498,36 @@ > } > } > } >- >- MethodBinding result = method.isConstructor() >- ? new MethodBinding(methodModifiers, parameters, exceptions, this) >- : new MethodBinding(methodModifiers, method.getSelector(), returnType, parameters, exceptions, this); >+ final AnnotationInstance[] methodAnnos = createAnnotations(method.getAnnotations()); >+ >+ final MethodBinding result; >+ if( method.isConstructor() ) >+ result = new BinaryMethodBinding(methodModifiers, >+ parameters, >+ exceptions, >+ this, >+ methodAnnos, >+ paramAnnotations); >+ else{ >+ if( isAnnotationType() ){ >+ result = new AnnotationMethodBinding(methodModifiers, >+ method.getSelector(), >+ returnType, >+ this, >+ methodAnnos, >+ paramAnnotations, >+ getMemberValue(method.getDefaultValue())); >+ } >+ else result = new BinaryMethodBinding(methodModifiers, >+ method.getSelector(), >+ returnType, >+ parameters, >+ exceptions, >+ this, >+ methodAnnos, >+ paramAnnotations); >+ } >+ > if (use15specifics) > result.tagBits |= method.getTagBits(); > result.typeVariables = typeVars; >@@ -413,6 +536,7 @@ > typeVars[i].declaringElement = result; > return result; > } >+ > /** > * Create method bindings for binary type, filtering out <clinit> and synthetics > */ >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java,v >retrieving revision 1.107 >diff -u -r1.107 ClassScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 21 Mar 2005 12:51:43 -0000 1.107 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 14 Apr 2005 03:18:03 -0000 >@@ -60,7 +60,7 @@ > if (hierarchyIsInconsistent) { // 72468 > referenceContext.binding.fields = new FieldBinding[1]; > referenceContext.binding.fields[0] = >- new FieldBinding(IncompleteHierarchy, IntBinding, AccPrivate, referenceContext.binding, null); >+ new SourceFieldBinding(IncompleteHierarchy, IntBinding, AccPrivate, referenceContext.binding, null); > } else { > referenceContext.binding.fields = NoFields; > } >@@ -91,7 +91,7 @@ > if (referenceContext.binding.isInterface()) > problemReporter().interfaceCannotHaveInitializers(referenceContext.binding, field); > } else { >- FieldBinding fieldBinding = new FieldBinding(field, null, field.modifiers | AccUnresolved, referenceContext.binding); >+ FieldBinding fieldBinding = new SourceFieldBinding(field, null, field.modifiers | AccUnresolved, referenceContext.binding); > // field's type will be resolved when needed for top level types > checkAndSetModifiersForField(fieldBinding, field); > >@@ -133,7 +133,7 @@ > fieldBindings = newFieldBindings; > } > if (hierarchyIsInconsistent) >- fieldBindings[count++] = new FieldBinding(IncompleteHierarchy, IntBinding, AccPrivate, referenceContext.binding, null); >+ fieldBindings[count++] = new SourceFieldBinding(IncompleteHierarchy, IntBinding, AccPrivate, referenceContext.binding, null); > > if (count != fieldBindings.length) > System.arraycopy(fieldBindings, 0, fieldBindings = new FieldBinding[count], 0, count); >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java,v >retrieving revision 1.30 >diff -u -r1.30 FieldBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java 15 Mar 2005 10:43:16 -0000 1.30 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java 14 Apr 2005 03:18:03 -0000 >@@ -12,30 +12,37 @@ > > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.ast.ASTNode; >+import org.eclipse.jdt.internal.compiler.ast.Annotation; > import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; > import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; > import org.eclipse.jdt.internal.compiler.impl.Constant; > >-public class FieldBinding extends VariableBinding { >- public ReferenceBinding declaringClass; >+public abstract class FieldBinding extends VariableBinding implements TypeConstants { >+ public ReferenceBinding declaringClass; >+ > protected FieldBinding() { > super(null, null, 0, null); > // for creating problem field > } >-public FieldBinding(char[] name, TypeBinding type, int modifiers, ReferenceBinding declaringClass, Constant constant) { >+ >+FieldBinding(char[] name, >+ TypeBinding type, >+ int modifiers, >+ ReferenceBinding declaringClass, >+ Constant constant) >+{ > super(name, type, modifiers, constant); > this.declaringClass = declaringClass; > } >-public FieldBinding(FieldDeclaration field, TypeBinding type, int modifiers, ReferenceBinding declaringClass) { >- this(field.name, type, modifiers, declaringClass, null); >- field.binding = this; // record binding in declaration >-} >+ > // special API used to change field declaring class for runtime visibility check >-public FieldBinding(FieldBinding initialFieldBinding, ReferenceBinding declaringClass) { >- super(initialFieldBinding.name, initialFieldBinding.type, initialFieldBinding.modifiers, initialFieldBinding.constant()); >+FieldBinding(FieldBinding initialFieldBinding, ReferenceBinding declaringClass) { >+ super(initialFieldBinding.name, initialFieldBinding.type, initialFieldBinding.modifiers, >+ initialFieldBinding.constant()); > this.declaringClass = declaringClass; > this.id = initialFieldBinding.id; > } >+ > /* API > * Answer the receiver's binding type from Binding.BindingID. > */ >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java,v >retrieving revision 1.29 >diff -u -r1.29 LocalVariableBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java 23 Feb 2005 02:47:30 -0000 1.29 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java 14 Apr 2005 03:18:03 -0000 >@@ -10,13 +10,15 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.lookup; > >+import org.eclipse.jdt.internal.compiler.ast.ASTNode; > import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; >+import org.eclipse.jdt.internal.compiler.ast.Annotation; > import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; > import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; > import org.eclipse.jdt.internal.compiler.impl.Constant; > import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; > >-public class LocalVariableBinding extends VariableBinding { >+public class LocalVariableBinding extends VariableBinding implements TypeConstants { > > public boolean isArgument; > public int resolvedPosition; // for code generation (position in method context) >@@ -128,6 +130,24 @@ > initializationCount++; > } > } >+ >+ public AnnotationInstance[] getAnnotations() >+ { >+ if( this.isArgument && this.declaration != null){ >+ final Annotation[] argAnnos = declaration.annotations; >+ final int numAnnotations = argAnnos == null ? 0 : argAnnos.length; >+ AnnotationInstance[] result = NoAnnotations; >+ if( numAnnotations > 0 ){ >+ result = new SourceAnnotation[numAnnotations]; >+ // check for errors >+ ASTNode.resolveAnnotations(declaringScope, argAnnos, this); >+ for( int j=0; j<numAnnotations; j++ ){ >+ result[j] = new SourceAnnotation(argAnnos[j]); >+ } >+ } >+ } >+ return null; >+ } > > public String toString() { > >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java,v >retrieving revision 1.58 >diff -u -r1.58 MethodBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 15 Mar 2005 10:43:16 -0000 1.58 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 14 Apr 2005 03:18:04 -0000 >@@ -16,22 +16,46 @@ > import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; > import org.eclipse.jdt.internal.compiler.codegen.ConstantPool; > >-public class MethodBinding extends Binding implements BaseTypes, TypeConstants { >- >+public abstract class MethodBinding extends Binding implements BaseTypes, TypeConstants >+{ > public int modifiers; > public char[] selector; > public TypeBinding returnType; > public TypeBinding[] parameters; > public ReferenceBinding[] thrownExceptions; > public ReferenceBinding declaringClass; >- public TypeVariableBinding[] typeVariables = NoTypeVariables; >+ public TypeVariableBinding[] typeVariables = NoTypeVariables; >+ >+ /** >+ * In the majority of the time, there will no annotations at all. >+ * We will try to optimized the storage by packing both >+ * method and parameter annotation into one field. >+ * >+ * If there are no annotations and no parameter annotations, >+ * this will be a zero-length array. >+ * If this is an array of size 1, then method annotations are intialized and there >+ * may or may not be parameter annotations. >+ * If there are ever any parameter annotations, this will be an array of size > 1. >+ * </code>null</code> in the array means not initialized. >+ * If the field is <code>null</code> this means it is not initalized at all. >+ * Binary types should always initialize this field; >+ * Method annotations are always at index 0 and parameter annotations >+ * always start at index 1 if they are ever present. >+ */ >+ private AnnotationInstance[][] extendedModifiers = null; > char[] signature; > public long tagBits; > > protected MethodBinding() { > // for creating problem or synthetic method > } >-public MethodBinding(int modifiers, char[] selector, TypeBinding returnType, TypeBinding[] parameters, ReferenceBinding[] thrownExceptions, ReferenceBinding declaringClass) { >+protected MethodBinding(int modifiers, >+ char[] selector, >+ TypeBinding returnType, >+ TypeBinding[] parameters, >+ ReferenceBinding[] thrownExceptions, >+ ReferenceBinding declaringClass) >+{ > this.modifiers = modifiers; > this.selector = selector; > this.returnType = returnType; >@@ -46,18 +70,28 @@ > this.modifiers |= AccStrictfp; > } > } >-public MethodBinding(int modifiers, TypeBinding[] parameters, ReferenceBinding[] thrownExceptions, ReferenceBinding declaringClass) { >+ >+// constructor for creating binding representing constructor >+protected MethodBinding(int modifiers, >+ TypeBinding[] parameters, >+ ReferenceBinding[] thrownExceptions, >+ ReferenceBinding declaringClass) >+{ > this(modifiers, TypeConstants.INIT, VoidBinding, parameters, thrownExceptions, declaringClass); > } >+ >+ > // special API used to change method declaring class for runtime visibility check >-public MethodBinding(MethodBinding initialMethodBinding, ReferenceBinding declaringClass) { >+protected MethodBinding(MethodBinding initialMethodBinding, ReferenceBinding declaringClass) { > this.modifiers = initialMethodBinding.modifiers; > this.selector = initialMethodBinding.selector; > this.returnType = initialMethodBinding.returnType; > this.parameters = initialMethodBinding.parameters; > this.thrownExceptions = initialMethodBinding.thrownExceptions; > this.declaringClass = declaringClass; >+ this.extendedModifiers = initialMethodBinding.extendedModifiers; > } >+ > /* Answer true if the argument types & the receiver's parameters are equal > */ > public final boolean areParametersEqual(MethodBinding method) { >@@ -365,6 +399,23 @@ > } > > /** >+ * @return the annotations annotating this method. >+ * Return a zero-length array if none is found. >+ */ >+public abstract AnnotationInstance[] getAnnotations(); >+ >+ >+ >+/** >+ * @param index the index of the parameter of interest >+ * @return the annotations on the <code>index</code>th parameter >+ * @throws ArrayIndexOutOfBoundsException when <code>index</code> is not valid >+ */ >+public abstract AnnotationInstance[] getParameterAnnotations(final int index); >+ >+ >+ >+/** > * Compute the tagbits for standard annotations. For source types, these could require > * lazily resolving corresponding annotation nodes, in case of forward references. > * @see org.eclipse.jdt.internal.compiler.lookup.Binding#getAnnotationTagBits() >@@ -733,4 +784,11 @@ > public TypeVariableBinding[] typeVariables() { > return this.typeVariables; > } >+ >+/** >+ * @return the default value iff this is an annotation method. >+ * Return <code>null</code> if there is no default value or >+ * if this is not an annotaion method. >+ */ >+public abstract Object getDefaultValue(); > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java,v >retrieving revision 1.52 >diff -u -r1.52 MethodScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java 21 Mar 2005 09:57:47 -0000 1.52 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java 14 Apr 2005 03:18:04 -0000 >@@ -287,13 +287,18 @@ > if (method.isConstructor()) { > if (method.isDefaultConstructor()) > modifiers |= AccIsDefaultConstructor; >- method.binding = new MethodBinding(modifiers, null, null, declaringClass); >+ method.binding = new SourceMethodBinding(modifiers, null, null, declaringClass); > checkAndSetModifiersForConstructor(method.binding); > } else { > if (declaringClass.isInterface()) // interface or annotation type >- modifiers |= AccPublic | AccAbstract; >- method.binding = >- new MethodBinding(modifiers, method.selector, null, null, null, declaringClass); >+ modifiers |= AccPublic | AccAbstract; >+ >+ method.binding = new SourceMethodBinding(modifiers, >+ method.selector, >+ null, >+ null, >+ null, >+ declaringClass); > checkAndSetModifiersForMethod(method.binding); > } > this.isStatic = method.binding.isStatic(); >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedFieldBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedFieldBinding.java,v >retrieving revision 1.8 >diff -u -r1.8 ParameterizedFieldBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedFieldBinding.java 23 Feb 2005 02:47:30 -0000 1.8 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedFieldBinding.java 14 Apr 2005 03:18:05 -0000 >@@ -55,6 +55,11 @@ > */ > public void setConstant(Constant constant) { > this.originalField.setConstant(constant); >- } >+ } >+ >+ public AnnotationInstance[] getAnnotations() >+ { >+ return original().getAnnotations(); >+ } > } > >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java,v >retrieving revision 1.7 >diff -u -r1.7 ParameterizedMethodBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java 23 Feb 2005 02:47:30 -0000 1.7 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java 14 Apr 2005 03:18:05 -0000 >@@ -18,6 +18,7 @@ > * their signature did involve generics or not, so as to get the proper declaringClass for > * these methods. > */ >+ > public class ParameterizedMethodBinding extends MethodBinding { > > protected MethodBinding originalMethod; >@@ -143,4 +144,19 @@ > public MethodBinding original() { > return this.originalMethod.original(); > } >+ >+ public AnnotationInstance[] getAnnotations() >+ { >+ return original().getAnnotations(); >+ } >+ >+ public AnnotationInstance[] getParameterAnnotations(int index) >+ { >+ return original().getParameterAnnotations(index); >+ } >+ >+ public Object getDefaultValue() >+ { >+ return original().getDefaultValue(); >+ } > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java,v >retrieving revision 1.10 >diff -u -r1.10 ProblemFieldBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java 23 Feb 2005 02:47:30 -0000 1.10 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java 14 Apr 2005 03:18:05 -0000 >@@ -38,4 +38,6 @@ > public final int problemId() { > return problemId; > } >+ >+public AnnotationInstance[] getAnnotations(){ return NoAnnotations; } > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java,v >retrieving revision 1.10 >diff -u -r1.10 ProblemMethodBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java 23 Feb 2005 02:47:30 -0000 1.10 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java 14 Apr 2005 03:18:05 -0000 >@@ -39,4 +39,8 @@ > public final int problemId() { > return this.problemReason; > } >+ >+public AnnotationInstance[] getAnnotations(){ return NoAnnotations; } >+public AnnotationInstance[] getParameterAnnotations(int index){ return NoAnnotations; } >+public Object getDefaultValue(){ return null; } > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java,v >retrieving revision 1.66 >diff -u -r1.66 ReferenceBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 15 Mar 2005 10:43:16 -0000 1.66 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 14 Apr 2005 03:18:06 -0000 >@@ -33,7 +33,6 @@ > public char[] sourceName; > public int modifiers; > public PackageBinding fPackage; >- > char[] fileName; > char[] constantPoolName; > char[] signature; >@@ -857,4 +856,11 @@ > MethodBinding[] unResolvedMethods() { // for the MethodVerifier so it doesn't resolve types > return methods(); > } >+/** >+ * @return the JSR 175 annotations that annotate this type. >+ */ >+public AnnotationInstance[] getAnnotations() >+{ >+ return NoAnnotations; >+} > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v >retrieving revision 1.89 >diff -u -r1.89 SourceTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 26 Mar 2005 23:39:49 -0000 1.89 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 14 Apr 2005 03:18:07 -0000 >@@ -62,7 +62,7 @@ > computeId(); > } > private void addDefaultAbstractMethod(MethodBinding abstractMethod) { >- MethodBinding defaultAbstract = new MethodBinding( >+ MethodBinding defaultAbstract = new SourceMethodBinding( > abstractMethod.modifiers | AccDefaultAbstract, > abstractMethod.selector, > abstractMethod.returnType, >@@ -633,6 +633,23 @@ > } > return this.tagBits; > } >+ >+public AnnotationInstance[] getAnnotations() { >+ // make sure we first go resolve the annoations and report any problems found. >+ getAnnotationTagBits(); >+ final TypeDeclaration typeDecl = this.scope.referenceContext; >+ final int numAnnotations = typeDecl.annotations == null ? 0 : typeDecl.annotations.length; >+ if( numAnnotations == 0 ) >+ return NoAnnotations; >+ else{ >+ final AnnotationInstance[] instances = new AnnotationInstance[numAnnotations]; >+ for( int i=0; i<numAnnotations; i++ ){ >+ instances[i] = new SourceAnnotation(typeDecl.annotations[i]); >+ } >+ return instances; >+ } >+} >+ > public MethodBinding[] getDefaultAbstractMethods() { > int count = 0; > for (int i = methods.length; --i >= 0;) >@@ -894,7 +911,10 @@ > } > FieldBinding updatedField = (FieldBinding) fieldMap.get(newDeclaringClass); > if (updatedField == null){ >- updatedField = new FieldBinding(targetField, newDeclaringClass); >+ if( targetField instanceof SourceFieldBinding ) >+ updatedField = new SourceFieldBinding((SourceFieldBinding)targetField, newDeclaringClass); >+ else >+ updatedField = new BinaryFieldBinding((BinaryFieldBinding)targetField, newDeclaringClass); > fieldMap.put(newDeclaringClass, updatedField); > } > return updatedField; >@@ -912,7 +932,10 @@ > } > MethodBinding updatedMethod = (MethodBinding) methodMap.get(newDeclaringClass); > if (updatedMethod == null){ >- updatedMethod = new MethodBinding(targetMethod, newDeclaringClass); >+ if( targetMethod instanceof SourceMethodBinding ) >+ updatedMethod = new SourceMethodBinding((SourceMethodBinding)targetMethod, newDeclaringClass); >+ else >+ updatedMethod = new BinaryMethodBinding((BinaryMethodBinding)targetMethod, newDeclaringClass); > methodMap.put(newDeclaringClass, updatedMethod); > } > return updatedMethod; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticArgumentBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticArgumentBinding.java,v >retrieving revision 1.12 >diff -u -r1.12 SyntheticArgumentBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticArgumentBinding.java 23 Feb 2005 02:47:30 -0000 1.12 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticArgumentBinding.java 14 Apr 2005 03:18:07 -0000 >@@ -55,4 +55,8 @@ > AccFinal, > true); > } >+ >+ public AnnotationInstance[] getAnnotations(){ >+ return isArgument ? NoAnnotations : null; >+ } > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticFieldBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticFieldBinding.java,v >retrieving revision 1.8 >diff -u -r1.8 SyntheticFieldBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticFieldBinding.java 15 Mar 2005 10:43:16 -0000 1.8 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticFieldBinding.java 14 Apr 2005 03:18:07 -0000 >@@ -21,4 +21,6 @@ > this.index = index; > this.tagBits |= TagBits.AnnotationResolved; > } >+ >+ public AnnotationInstance[] getAnnotations(){ return NoAnnotations; } > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java,v >retrieving revision 1.5 >diff -u -r1.5 SyntheticMethodBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java 15 Mar 2005 10:43:16 -0000 1.5 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java 14 Apr 2005 03:18:08 -0000 >@@ -335,4 +335,8 @@ > protected boolean isConstructorRelated() { > return kind == ConstructorAccess; > } >+ >+ public AnnotationInstance[] getAnnotations(){ return NoAnnotations; } >+ public AnnotationInstance[] getParameterAnnotations(int paramIndex){ return NoAnnotations; } >+ public Object getDefaultValue(){ return null; } > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java,v >retrieving revision 1.36 >diff -u -r1.36 TypeConstants.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java 10 Mar 2005 16:28:15 -0000 1.36 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java 14 Apr 2005 03:18:08 -0000 >@@ -133,6 +133,9 @@ > ReferenceBinding[] NoSuperInterfaces = new ReferenceBinding[0]; > ReferenceBinding[] NoMemberTypes = new ReferenceBinding[0]; > TypeVariableBinding[] NoTypeVariables = new TypeVariableBinding[0]; >+ AnnotationInstance[] NoAnnotations = new AnnotationInstance[0]; >+ ElementValuePair[] NoElementValuePairs = new ElementValuePair[0]; >+ AnnotationInstance[][] NoParamAnnotations = new AnnotationInstance[0][0]; > > // Synthetics > char[] INIT = "<init>".toCharArray(); //$NON-NLS-1$ >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/UpdatedMethodBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UpdatedMethodBinding.java,v >retrieving revision 1.3 >diff -u -r1.3 UpdatedMethodBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/UpdatedMethodBinding.java 23 Feb 2005 02:47:30 -0000 1.3 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/UpdatedMethodBinding.java 14 Apr 2005 03:18:08 -0000 >@@ -22,4 +22,7 @@ > public TypeBinding constantPoolDeclaringClass() { > return this.updatedDeclaringClass; > } >+ public AnnotationInstance[] getAnnotations(){ return NoAnnotations; } >+ public AnnotationInstance[] getParameterAnnotations(int index){ return NoAnnotations; } >+ public Object getDefaultValue(){ return null; } > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java,v >retrieving revision 1.21 >diff -u -r1.21 VariableBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java 23 Feb 2005 02:47:30 -0000 1.21 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java 14 Apr 2005 03:18:08 -0000 >@@ -51,10 +51,16 @@ > public void setConstant(Constant constant) { > this.constant = constant; > } >+ /** >+ * @return the annotations iff this is a field, enum constant or parameter. >+ * Return null otherwise. >+ */ >+ public abstract AnnotationInstance[] getAnnotations(); >+ > public String toString() { > String s = (type != null) ? type.debugName() : "UNDEFINED TYPE"; //$NON-NLS-1$ > s += " "; //$NON-NLS-1$ > s += (name != null) ? new String(name) : "UNNAMED FIELD"; //$NON-NLS-1$ > return s; >- } >+ } > } >Index: dom/org/eclipse/jdt/core/dom/ASTConverter.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java,v >retrieving revision 1.202 >diff -u -r1.202 ASTConverter.java >--- dom/org/eclipse/jdt/core/dom/ASTConverter.java 26 Mar 2005 23:39:49 -0000 1.202 >+++ dom/org/eclipse/jdt/core/dom/ASTConverter.java 14 Apr 2005 03:18:22 -0000 >@@ -1892,6 +1892,7 @@ > markerAnnotation.setSourceRange(start, end - start + 1); > if (this.resolveBindings) { > recordNodes(markerAnnotation, annotation); >+ markerAnnotation.resolveAnnotation(); > } > return markerAnnotation; > } >@@ -1953,6 +1954,7 @@ > normalAnnotation.setSourceRange(start, end - start + 1); > if (this.resolveBindings) { > recordNodes(normalAnnotation, annotation); >+ normalAnnotation.resolveAnnotation(); > } > return normalAnnotation; > } >@@ -2129,6 +2131,7 @@ > singleMemberAnnotation.setSourceRange(start, end - start + 1); > if (this.resolveBindings) { > recordNodes(singleMemberAnnotation, annotation); >+ singleMemberAnnotation.resolveAnnotation(); > } > return singleMemberAnnotation; > } >Index: dom/org/eclipse/jdt/core/dom/Annotation.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Annotation.java,v >retrieving revision 1.11 >diff -u -r1.11 Annotation.java >--- dom/org/eclipse/jdt/core/dom/Annotation.java 15 Mar 2005 04:30:05 -0000 1.11 >+++ dom/org/eclipse/jdt/core/dom/Annotation.java 14 Apr 2005 03:18:25 -0000 >@@ -164,5 +164,8 @@ > int memSize() { > return BASE_NODE_SIZE + 1 * 4; > } >+ >+ public IAnnotationInstance resolveAnnotation() >+ { return this.ast.getBindingResolver().resolveAnnotation(this); } > } > >Index: dom/org/eclipse/jdt/core/dom/BindingResolver.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java,v >retrieving revision 1.39 >diff -u -r1.39 BindingResolver.java >--- dom/org/eclipse/jdt/core/dom/BindingResolver.java 23 Mar 2005 21:45:18 -0000 1.39 >+++ dom/org/eclipse/jdt/core/dom/BindingResolver.java 14 Apr 2005 03:18:26 -0000 >@@ -17,7 +17,8 @@ > > /** > * A binding resolver is an internal mechanism for figuring out the binding >- * for a major declaration, type, or name reference. >+ * for a major declaration, type, or name reference. This also handles >+ * the creation and mapping between annotations and the ast nodes that defines them > * <p> > * The default implementation serves as the default binding resolver > * that does no resolving whatsoever. Internal subclasses do all the real work. >@@ -91,6 +92,21 @@ > ASTNode findDeclaringNode(String bindingKey) { > return null; > } >+ >+ /** >+ * Finds the corresponding AST node from which the given annotation instance originated. >+ * >+ * The default implementation of this method returns <code>null</code>. >+ * Subclasses may reimplement. >+ * </p> >+ * >+ * @param instance the dom annotation >+ * @return the corresponding node where the bindings is declared, >+ * or <code>null</code> if none >+ */ >+ ASTNode findDeclaringNode(IAnnotationInstance instance){ >+ return null; >+ } > > /** > * Allows the user to get information about the given old/new pair of >@@ -164,6 +180,20 @@ > } > > /** >+ * Return the new annotation corresponding to the given old annotation >+ * <p> >+ * The default implementation of this method returns <code>null</code> >+ * Subclasses may reimplement. >+ * </p> >+ * >+ * @param instance the old annotation >+ * @return the new DOM annotation >+ */ >+ IAnnotationInstance getAnnotationInstance(org.eclipse.jdt.internal.compiler.lookup.AnnotationInstance instance){ >+ return null; >+ } >+ >+ /** > * Returns the compiler lookup environment used by this binding resolver. > * Returns <code>null</code> if none. > * >@@ -785,6 +815,25 @@ > } > > /** >+ * Resolves the given annotation instance and returns the DOM representation for it. >+ * <p> >+ * The implementation of {@link Annotation#resolveAnnotation()} >+ * forwards to this method. >+ * </p> >+ * <p> >+ * The default implementation of this method returns <code>null</code>. >+ * Subclasses may reimplement. >+ * </p> >+ * >+ * @param annotation the annotation ast node of interest >+ * @return the DOM annotation representation for the given ast node, or >+ * <code>null</code> if none is available >+ */ >+ IAnnotationInstance resolveAnnotation(Annotation annotation){ >+ return null; >+ } >+ >+ /** > * Returns the compilation unit scope used by this binding resolver. > * Returns <code>null</code> if none. > * >Index: dom/org/eclipse/jdt/core/dom/CompilationUnit.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java,v >retrieving revision 1.65 >diff -u -r1.65 CompilationUnit.java >--- dom/org/eclipse/jdt/core/dom/CompilationUnit.java 15 Mar 2005 04:30:05 -0000 1.65 >+++ dom/org/eclipse/jdt/core/dom/CompilationUnit.java 14 Apr 2005 03:18:27 -0000 >@@ -406,6 +406,24 @@ > public ASTNode findDeclaringNode(IBinding binding) { > return this.ast.getBindingResolver().findDeclaringNode(binding); > } >+ >+ /** >+ * Finds the corresponding AST node in the given compilation unit from >+ * which the given binding originated. Returns <code>null</code> if the >+ * binding does not correspond to any node in this compilation unit. >+ * >+ * This method always returns >+ * <code>null</code> when the binding object comes from a different AST. >+ * >+ * @param instance the binding >+ * @return the corresponding node where the given binding is declared, >+ * or <code>null</code> if the binding does not correspond to a node in this >+ * compilation unit or if bindings were not requested when this AST was built >+ * @see #findDeclaringNode(String) >+ */ >+ public ASTNode findDeclaringNode(IAnnotationInstance instance) { >+ return this.ast.getBindingResolver().findDeclaringNode(instance); >+ } > > /** > * Finds the corresponding AST node in the given compilation unit from >Index: dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java,v >retrieving revision 1.132 >diff -u -r1.132 DefaultBindingResolver.java >--- dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 23 Mar 2005 21:45:18 -0000 1.132 >+++ dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 14 Apr 2005 03:18:28 -0000 >@@ -90,8 +90,11 @@ > Map bindingKeysToBindings; > /** > * This map is used to keep the correspondance between new bindings and the >- * compiler bindings. This is an identity map. We should only create one object >- * for one binding. >+ * compiler bindings as well as new annotation instances to their >+ * internal counterpart. >+ * This is an identity map. We should only create one object >+ * for one binding or annotation. >+ * > */ > Map compilerBindingsToASTBindings; > >@@ -107,7 +110,7 @@ > Map astNodesToBlockScope; > > /** >- * This map is used to get an ast node from its binding (new binding) >+ * This map is used to get an ast node from its binding (new binding) or DOM > */ > Map bindingsToAstNodes; > >@@ -183,6 +186,13 @@ > return (ASTNode) this.bindingsToAstNodes.get(binding); > } > >+ synchronized ASTNode findDeclaringNode(IAnnotationInstance instance) >+ { >+ if( instance == null ) >+ return null; >+ return (ASTNode)this.bindingsToAstNodes.get(instance); >+ } >+ > IBinding getBinding(org.eclipse.jdt.internal.compiler.lookup.Binding binding) { > switch (binding.kind()) { > case Binding.PACKAGE: >@@ -351,6 +361,17 @@ > return null; > } > >+ synchronized IAnnotationInstance getAnnotationInstance(org.eclipse.jdt.internal.compiler.lookup.AnnotationInstance internalInstance){ >+ IAnnotationInstance domInstance = >+ (IAnnotationInstance) this.bindingTables.compilerBindingsToASTBindings.get(internalInstance); >+ if (domInstance != null) { >+ return domInstance; >+ } >+ domInstance = new AnnotationInstance(internalInstance, this); >+ this.bindingTables.compilerBindingsToASTBindings.put(internalInstance, domInstance); >+ return domInstance; >+ } >+ > /* > * Method declared on BindingResolver. > */ >@@ -1398,6 +1419,23 @@ > return null; > } > >+ synchronized IAnnotationInstance resolveAnnotation(final Annotation domASTNode) >+ { >+ Object oldNode = this.newAstToOldAst.get(domASTNode); >+ if (oldNode instanceof org.eclipse.jdt.internal.compiler.ast.Annotation) { >+ org.eclipse.jdt.internal.compiler.ast.Annotation internalAstNode = >+ (org.eclipse.jdt.internal.compiler.ast.Annotation) oldNode; >+ >+ IAnnotationInstance domAnnotation = this.getAnnotationInstance(internalAstNode.compilerAnnotation); >+ if (domAnnotation == null) { >+ return null; >+ } >+ this.bindingsToAstNodes.put(domAnnotation, domASTNode); >+ return domAnnotation; >+ } >+ return null; >+ } >+ > /* > * Method declared on BindingResolver. > */ >Index: dom/org/eclipse/jdt/core/dom/IMethodBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IMethodBinding.java,v >retrieving revision 1.24 >diff -u -r1.24 IMethodBinding.java >--- dom/org/eclipse/jdt/core/dom/IMethodBinding.java 24 Mar 2005 13:12:31 -0000 1.24 >+++ dom/org/eclipse/jdt/core/dom/IMethodBinding.java 14 Apr 2005 03:18:30 -0000 >@@ -42,8 +42,8 @@ > * @return <code>true</code> if this is the binding for a constructor, > * and <code>false</code> if this is the binding for a method > */ >- public boolean isConstructor(); >- >+ public boolean isConstructor(); >+ > /** > * Returns whether this binding is known to be a compiler-generated > * default constructor. >@@ -266,6 +266,38 @@ > public boolean isVarargs(); > > /** >+ * Return whether this binding is for an annotation method. >+ * >+ * @return <code>true</code> iff this is the binding for an annotation method >+ * and <code>false</code> otherwise. >+ */ >+ public boolean isAnnotationMethod(); >+ >+ /** >+ * Return the default value of an annotation method, iff this method >+ * binding represents an annotation method that has a default value. >+ * Return <code>null</code> otherwise. >+ * >+ * >+ * If the type of the value is a primitive type, the result is the boxed equivalent >+ * (i.e., int returned as an <code>Integer</code>). If the type of the value is >+ * <code>String</code>, the result is the string itself. If the type of the value >+ * is an enum type, <code>IVariableBinding</code> is returned. If the type of the >+ * value is an annotation type, <code>IAnnotationInstance</code> is returned. >+ * If the type of the value is an array, then an one-dimensional array will be >+ * returned. If there are not defaulta value, the result is <code>null</code>. >+ * >+ * >+ * @return the default value of an annotation method. Return <code>null</code> >+ * if one does not exist or if this binding is not an annotation method binding. >+ * This will also return <code>null</code> if no binding information is requested >+ * when this DOM/AST is built. >+ * >+ */ >+ public Object getDefaultValue(); >+ >+ >+ /** > * Returns whether this method overrides the given method, > * as specified in section 6.4.2 of <em>The Java Language > * Specification, Second Edition</em> (JLS2). >@@ -276,4 +308,25 @@ > * @since 3.1 > */ > public boolean overrides(IMethodBinding method); >+ >+ /** >+ * Return the annotations annotating this method/constructor. >+ * The behavior of this API is the same regardless of whether >+ * this is a parameterized method or not. >+ * >+ * @return the annotations annotating this method/costructor. >+ */ >+ public IAnnotationInstance[] getAnnotations(); >+ >+ /** >+ * Return the annotations of a parameter of this method. >+ * The behavior of this API is the same regardless of whether >+ * this is a parameterized method or not. >+ * >+ * @param paramIndex the index of the parameter of interest. >+ * @return the annotations of the <code>paramIndex</code>th parameter >+ * @throws ArrayIndexOutOfBoundsException if <code>paramIndex</code> is >+ * not a valid index. >+ */ >+ public IAnnotationInstance[] getParameterAnnotations(int paramIndex); > } >Index: dom/org/eclipse/jdt/core/dom/ITypeBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ITypeBinding.java,v >retrieving revision 1.44 >diff -u -r1.44 ITypeBinding.java >--- dom/org/eclipse/jdt/core/dom/ITypeBinding.java 24 Mar 2005 21:01:15 -0000 1.44 >+++ dom/org/eclipse/jdt/core/dom/ITypeBinding.java 14 Apr 2005 03:18:30 -0000 >@@ -792,4 +792,19 @@ > * @since 2.1 > */ > public String getQualifiedName(); >+ >+ /** >+ * Return the annotations iff one of {@link #isAnnotation()}, {@link #isEnum}, >+ * {@link #isClass} or {@link #isInterface()} returns <code>true</code>. >+ * Return null otherwise. >+ * >+ * @return the annotations annotating the type if it is a reference type. >+ * Return null otherwise. >+ * @see #isAnnotation() >+ * @see #isEnum() >+ * @see #isClass() >+ * @see #isInterface() >+ * @since 3.1 >+ */ >+ public IAnnotationInstance[] getAnnotations(); > } >Index: dom/org/eclipse/jdt/core/dom/IVariableBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IVariableBinding.java,v >retrieving revision 1.14 >diff -u -r1.14 IVariableBinding.java >--- dom/org/eclipse/jdt/core/dom/IVariableBinding.java 25 Feb 2005 14:42:45 -0000 1.14 >+++ dom/org/eclipse/jdt/core/dom/IVariableBinding.java 14 Apr 2005 03:18:30 -0000 >@@ -150,5 +150,20 @@ > * @since 3.1 > */ > public IVariableBinding getVariableDeclaration(); >+ >+ /** >+ * Return the annotations annotating this variable if {@link #isField()} or >+ * {@link #isEnumConstant()} return <code>true</code> or this binding >+ * is a parameter. >+ * If this is a field, the behavior of this API is the same regardless of whether >+ * it is parameterized or not. >+ * >+ * @return the annotations of this variable iff it is a field, an enum constant >+ * or an parameter. Return <code>null</code> otherwise. >+ * @see #isEnumConstant() >+ * @see #isField() >+ * @since 3.1 >+ */ >+ public IAnnotationInstance[] getAnnotations(); > > } >Index: dom/org/eclipse/jdt/core/dom/MethodBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java,v >retrieving revision 1.56 >diff -u -r1.56 MethodBinding.java >--- dom/org/eclipse/jdt/core/dom/MethodBinding.java 15 Mar 2005 19:28:59 -0000 1.56 >+++ dom/org/eclipse/jdt/core/dom/MethodBinding.java 14 Apr 2005 03:18:31 -0000 >@@ -383,7 +383,49 @@ > MethodVerifier methodVerifier = lookupEnvironment.methodVerifier(); > return methodVerifier.doesMethodOverride(this.binding, otherCompilerBinding); > } >+ >+ public IAnnotationInstance[] getAnnotations(){ >+ final org.eclipse.jdt.internal.compiler.lookup.AnnotationInstance[] internalAnnotations = >+ this.binding.getAnnotations(); >+ final int len = internalAnnotations == null ? 0 : internalAnnotations.length; >+ IAnnotationInstance[] domInstances = AnnotationInstance.NoAnnotations; >+ if( len > 0 ){ >+ domInstances = new AnnotationInstance[len]; >+ for( int i=0; i<len; i++ ){ >+ domInstances[i] = this.resolver.getAnnotationInstance(internalAnnotations[i]); >+ } >+ } >+ return domInstances; >+ } >+ >+ public IAnnotationInstance[] getParameterAnnotations(int index){ >+ // this line may through <code>ArrayIndexOutOfBoundException()</code> if >+ // <code>index</code> is invalid >+ final org.eclipse.jdt.internal.compiler.lookup.AnnotationInstance[] internalAnnotations = >+ this.binding.getParameterAnnotations(index); >+ final int len = internalAnnotations == null ? 0 : internalAnnotations.length; >+ IAnnotationInstance[] domInstances = AnnotationInstance.NoAnnotations; >+ if( len > 0 ){ >+ domInstances = new AnnotationInstance[len]; >+ for( int i=0; i<len; i++ ){ >+ domInstances[i] = this.resolver.getAnnotationInstance(internalAnnotations[i]); >+ } >+ } >+ return domInstances; >+ } >+ >+ public boolean isAnnotationMethod() >+ { return this.binding instanceof org.eclipse.jdt.internal.compiler.lookup.AnnotationMethodBinding; } > >+ public Object getDefaultValue() >+ { >+ if( isAnnotationMethod() ){ >+ final Object internalObject = >+ ((org.eclipse.jdt.internal.compiler.lookup.AnnotationMethodBinding)this.binding).getDefaultValue(); >+ return ElementValuePair.buildDOMValue(internalObject, this.binding.returnType, this.resolver); >+ } >+ return null; >+ } > /* > * For debugging purpose only. > * @see java.lang.Object#toString() >Index: dom/org/eclipse/jdt/core/dom/TypeBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java,v >retrieving revision 1.93 >diff -u -r1.93 TypeBinding.java >--- dom/org/eclipse/jdt/core/dom/TypeBinding.java 26 Mar 2005 23:39:49 -0000 1.93 >+++ dom/org/eclipse/jdt/core/dom/TypeBinding.java 14 Apr 2005 03:18:35 -0000 >@@ -1029,6 +1029,27 @@ > return methodBinding.isDefaultAbstract() || methodBinding.isSynthetic() || (methodBinding.isConstructor() && isInterface()); > } > >+ public IAnnotationInstance[] getAnnotations(){ >+ if( this.binding.isAnnotationType() || this.binding.isClass() || >+ this.binding.isEnum() || this.binding.isInterface() ){ >+ final org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding refType = >+ (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding)this.binding; >+ final org.eclipse.jdt.internal.compiler.lookup.AnnotationInstance[] >+ internalAnnotations = refType.getAnnotations(); >+ >+ final int len = internalAnnotations == null ? 0 : internalAnnotations.length; >+ IAnnotationInstance[] domInstances = AnnotationInstance.NoAnnotations; >+ if( len > 0 ){ >+ domInstances = new AnnotationInstance[len]; >+ for( int i=0; i<len; i++ ){ >+ domInstances[i] = this.resolver.getAnnotationInstance(internalAnnotations[i]); >+ } >+ } >+ return domInstances; >+ } >+ return null; >+ } >+ > /* > * For debugging purpose only. > * @see java.lang.Object#toString() >Index: dom/org/eclipse/jdt/core/dom/VariableBinding.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java,v >retrieving revision 1.41 >diff -u -r1.41 VariableBinding.java >--- dom/org/eclipse/jdt/core/dom/VariableBinding.java 25 Feb 2005 17:33:37 -0000 1.41 >+++ dom/org/eclipse/jdt/core/dom/VariableBinding.java 14 Apr 2005 03:18:35 -0000 >@@ -289,6 +289,23 @@ > } > return false; > } >+ >+ public IAnnotationInstance[] getAnnotations() >+ { >+ final org.eclipse.jdt.internal.compiler.lookup.AnnotationInstance[] internalAnnotations = >+ this.binding.getAnnotations(); >+ // the variable is not an enum constant nor a field nor an argument. >+ if( internalAnnotations == null ) return null; >+ final int len = internalAnnotations.length; >+ IAnnotationInstance[] domInstances = AnnotationInstance.NoAnnotations; >+ if( len > 0 ){ >+ domInstances = new AnnotationInstance[len]; >+ for( int i=0; i<len; i++ ){ >+ domInstances[i] = this.resolver.getAnnotationInstance(internalAnnotations[i]); >+ } >+ } >+ return domInstances; >+ } > > /* > * For debugging purpose only. >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java,v >retrieving revision 1.34 >diff -u -r1.34 CodeSnippetScope.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java 22 Mar 2005 12:27:12 -0000 1.34 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java 14 Apr 2005 03:18:39 -0000 >@@ -12,6 +12,7 @@ > > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; >+import org.eclipse.jdt.internal.compiler.lookup.BinaryMethodBinding; > import org.eclipse.jdt.internal.compiler.lookup.Binding; > import org.eclipse.jdt.internal.compiler.lookup.BlockScope; > import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; >@@ -489,7 +490,13 @@ > if (methodBinding != null) { > // handle the method clone() specially... cannot be protected or throw exceptions > if (argumentTypes == NoParameters && CharOperation.equals(selector, CLONE)) >- return new MethodBinding((methodBinding.modifiers & ~AccProtected) | AccPublic, CLONE, methodBinding.returnType, argumentTypes, null, object); >+ return new BinaryMethodBinding((methodBinding.modifiers & ~AccProtected) | AccPublic, CLONE, >+ methodBinding.returnType, >+ argumentTypes, >+ null, >+ object, >+ null, >+ null); > if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) > return methodBinding; > } >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java,v >retrieving revision 1.31 >diff -u -r1.31 CodeSnippetSkeleton.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java 23 Feb 2005 02:47:30 -0000 1.31 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java 14 Apr 2005 03:18:40 -0000 >@@ -11,6 +11,7 @@ > package org.eclipse.jdt.internal.eval; > > import org.eclipse.jdt.core.compiler.CharOperation; >+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation; > import org.eclipse.jdt.internal.compiler.env.IBinaryField; > import org.eclipse.jdt.internal.compiler.env.IBinaryMethod; > import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType; >@@ -85,7 +86,16 @@ > } > public long getTagBits() { > return 0; >+ } >+ public IBinaryAnnotation[] getAnnotations() { >+ return null; >+ } >+ >+ public IBinaryAnnotation[] getParameterAnnotations(int index) { >+ return null; > } >+ >+ public Object getDefaultValue(){ return null; } > } > > /** >@@ -148,6 +158,10 @@ > public char[] sourceFileName() { > return null; > } >+ >+public IBinaryAnnotation[] getAnnotations() { >+ return null; >+} > public long getTagBits() { > return 0; > } >Index: model/org/eclipse/jdt/core/JavaCore.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v >retrieving revision 1.450 >diff -u -r1.450 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 1 Apr 2005 10:54:15 -0000 1.450 >+++ model/org/eclipse/jdt/core/JavaCore.java 14 Apr 2005 03:18:46 -0000 >@@ -68,6 +68,7 @@ > import org.eclipse.core.runtime.preferences.IEclipsePreferences; > import org.eclipse.core.runtime.preferences.IPreferencesService; > import org.eclipse.core.runtime.preferences.InstanceScope; >+import org.eclipse.jdt.core.compiler.ICompilationParticipant; > import org.eclipse.jdt.internal.compiler.util.SuffixConstants; > import org.eclipse.jdt.internal.core.*; > import org.eclipse.jdt.internal.core.util.MementoTokenizer; >@@ -1015,6 +1016,18 @@ > } > > /** >+ * Add a compilation participant listener dynamically. It is not necessary >+ * to call this for listeners registered with the compilationParticipants >+ * extension point. >+ * @param icp the listener >+ * @param eventMask the set of events for which the listener will be notified, >+ * built by ORing together values from CompilationParticipantEvent. >+ */ >+ public static void addCompilationParticipant(ICompilationParticipant icp, int eventMask) { >+ JavaModelManager.getJavaModelManager().getCompilationParticipants().add(icp, eventMask); >+ } >+ >+ /** > * Adds the given listener for changes to Java elements. > * Has no effect if an identical listener is already registered. > * >@@ -1515,7 +1528,23 @@ > public static String[] getClasspathVariableNames() { > return JavaModelManager.getJavaModelManager().variableNames(); > } >- >+ >+ /** >+ * Returns an immutable list containing the subset of registered >+ * listeners that have requested notification of at least one of >+ * the events in the flags mask. >+ * The first time this is called, it loads listeners from plugins, >+ * which may cause plugins to be loaded. If this is called on >+ * multiple threads simultaneously, or if loading a plugin causes >+ * this to be reentered, it may return an incomplete list of listeners, >+ * but it is guaranteed not to crash or deadlock. >+ * @param eventMask an ORed combination of values from ICompilationParticipant. >+ * @return an immutable list of ICompilationParticipant. >+ */ >+ public static List getCompilationParticipants(int eventMask) { >+ return JavaModelManager.getJavaModelManager().getCompilationParticipants().get(eventMask); >+ } >+ > /** > * Returns a table of all known configurable options with their default values. > * These options allow to configure the behaviour of the underlying components. >@@ -3567,6 +3596,17 @@ > } > > /** >+ * Removes the specified compilation participant listener. Has no effect >+ * if the listener was not on the list, or if it was registered via the >+ * compilationParticipant extension point rather than a call to >+ * addCompilationParticipant. >+ * @param icp the listener to remove >+ */ >+ public static void removeCompilationParticipant(ICompilationParticipant icp) { >+ JavaModelManager.getJavaModelManager().getCompilationParticipants().remove(icp); >+ } >+ >+ /** > * Removes the given element changed listener. > * Has no affect if an identical listener is not registered. > * >Index: model/org/eclipse/jdt/internal/core/CompilationUnit.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java,v >retrieving revision 1.205 >diff -u -r1.205 CompilationUnit.java >--- model/org/eclipse/jdt/internal/core/CompilationUnit.java 26 Mar 2005 17:05:12 -0000 1.205 >+++ model/org/eclipse/jdt/internal/core/CompilationUnit.java 14 Apr 2005 03:18:54 -0000 >@@ -15,8 +15,10 @@ > import org.eclipse.core.resources.*; > import org.eclipse.core.runtime.*; > import org.eclipse.jdt.core.*; >-import org.eclipse.jdt.core.compiler.*; >+import org.eclipse.jdt.core.compiler.CharOperation; >+import org.eclipse.jdt.core.compiler.ICompilationParticipant; > import org.eclipse.jdt.core.compiler.IProblem; >+import org.eclipse.jdt.core.compiler.PostReconcileCompilationEvent; > import org.eclipse.jdt.core.dom.AST; > import org.eclipse.jdt.internal.compiler.ASTVisitor; > import org.eclipse.jdt.internal.compiler.IProblemFactory; >@@ -25,6 +27,7 @@ > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; > import org.eclipse.jdt.internal.compiler.util.SuffixConstants; >+import org.eclipse.jdt.internal.core.JavaModelManager.PerWorkingCopyInfo; > import org.eclipse.jdt.internal.core.util.MementoTokenizer; > import org.eclipse.jdt.internal.core.util.Util; > >@@ -41,7 +44,20 @@ > > protected String name; > public WorkingCopyOwner owner; >+ >+ /** >+ * indicates if a NoOpProblemRequestor should be used when >+ * calling getPerWorkingCopyInfo >+ */ >+ private boolean useNoOpProblemRequestor = false; > >+ /** >+ * indicates if we should treat this working copy as inconsistent >+ * even if there wasn't a change in the underlying buffer. >+ */ >+ private boolean forceInconsistent = false; >+ >+ > /** > * Constructs a handle to a compilation unit with the given name in the > * specified package for the specified owner >@@ -758,8 +774,13 @@ > * Note: the use count of the per working copy info is NOT incremented. > */ > public JavaModelManager.PerWorkingCopyInfo getPerWorkingCopyInfo() { >- return JavaModelManager.getJavaModelManager().getPerWorkingCopyInfo(this, false/*don't create*/, false/*don't record usage*/, null/*no problem requestor needed*/); >+ >+ if ( useNoOpProblemRequestor ) >+ return new PerWorkingCopyInfo( this, NO_OP_PROBLEM_REQUESTOR ); >+ else >+ return JavaModelManager.getJavaModelManager().getPerWorkingCopyInfo(this, false/*don't create*/, false/*don't record usage*/, null/*no problem requestor needed*/); > } >+ > /* > * @see ICompilationUnit#getPrimary() > */ >@@ -900,7 +921,10 @@ > * @see IOpenable#isConsistent() > */ > public boolean isConsistent() { >- return JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().get(this) == null; >+ if ( forceInconsistent ) >+ return false; >+ else >+ return JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().get(this) == null; > } > /** > * >@@ -1084,8 +1108,58 @@ > // either way, request denied > createAST = false; > } >- ReconcileWorkingCopyOperation op = new ReconcileWorkingCopyOperation(this, createAST, astLevel, forceProblemDetection, workingCopyOwner); >- op.runOperation(monitor); >+ >+ >+ ReconcileWorkingCopyOperation op = null; >+ List l = JavaCore.getCompilationParticipants(ICompilationParticipant.POST_RECONCILE_EVENT); >+ if ( l != null && l.size() > 0 ) { >+ // we always need an AST to pass into compilation participants >+ op = new ReconcileWorkingCopyOperation(this, true /*createAST*/, AST.JLS3, forceProblemDetection, workingCopyOwner); >+ >+ // TODO: try not to use these two try-catch blocks here... >+ try { >+ try { >+ useNoOpProblemRequestor = true; >+ forceInconsistent = ! this.isConsistent(); >+ op.runOperation(monitor); >+ } >+ finally { >+ useNoOpProblemRequestor = false; >+ } >+ >+ Iterator it = l.iterator(); >+ while ( it.hasNext() ) { >+ ICompilationParticipant p = (ICompilationParticipant)it.next(); >+ PostReconcileCompilationEvent prce = new PostReconcileCompilationEvent( this, op.ast, getJavaProject() ); >+ p.notify( prce ); >+ // TODO: do something with the result of notify... >+ } >+ >+ // save off the original AST >+ org.eclipse.jdt.core.dom.CompilationUnit originalAst = op.ast; >+ >+ // if there were ICompilationParticipants, we will reconcile again and return the ast from the second reconcile >+ // this causes the client to receive an AST that is correct with respect to any changes that occurred in the >+ // ast as a result of files being added by compilation participants. This second reconcile also causes any >+ // problems to be reported to the correct problemRequestor, instead of the no-op problemRequestor. >+ op = new ReconcileWorkingCopyOperation(this, createAST, astLevel, forceProblemDetection, workingCopyOwner); >+ op.runOperation(monitor); >+ >+ // if the original AST was null, assume that the working copy was consistent. >+ // and return null. >+ if ( originalAst == null ) >+ return null; >+ } >+ finally { >+ forceInconsistent = false; >+ } >+ } >+ else >+ { >+ op = new ReconcileWorkingCopyOperation(this, createAST, astLevel, forceProblemDetection, workingCopyOwner); >+ op.runOperation(monitor); >+ } >+ > return op.ast; > } > >@@ -1162,4 +1236,14 @@ > ((CompilationUnitElementInfo) getElementInfo()).timestamp = timeStamp; > } > >+ >+ >+private final static NoOpProblemRequestor NO_OP_PROBLEM_REQUESTOR = new NoOpProblemRequestor(); >+private final static class NoOpProblemRequestor implements IProblemRequestor { >+ public void acceptProblem(IProblem problem) { /* no-op */ } >+ public void beginReporting() { /* no-op */ } >+ public void endReporting() { /* no-op */ } >+ public boolean isActive() { return true; } >+} >+ > } >Index: model/org/eclipse/jdt/internal/core/JavaModelManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java,v >retrieving revision 1.256 >diff -u -r1.256 JavaModelManager.java >--- model/org/eclipse/jdt/internal/core/JavaModelManager.java 30 Mar 2005 16:33:58 -0000 1.256 >+++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 14 Apr 2005 03:18:59 -0000 >@@ -23,6 +23,7 @@ > import org.eclipse.core.runtime.preferences.IEclipsePreferences; > import org.eclipse.jdt.core.*; > import org.eclipse.jdt.core.compiler.CharOperation; >+import org.eclipse.jdt.core.compiler.ICompilationParticipant; > import org.eclipse.jdt.core.compiler.IProblem; > import org.eclipse.jdt.internal.codeassist.CompletionEngine; > import org.eclipse.jdt.internal.codeassist.SelectionEngine; >@@ -105,6 +106,11 @@ > public static final String FORMATTER_EXTPOINT_ID = "codeFormatter" ; //$NON-NLS-1$ > > /** >+ * Name of the extension point for contributing a compilation participant >+ */ >+ public static final String COMPILATION_PARTICIPANT_EXTPOINT_ID = "compilationParticipant" ; //$NON-NLS-1$ >+ >+ /** > * Value of the content-type for Java source files > */ > public static final String JAVA_SOURCE_CONTENT_TYPE = JavaCore.PLUGIN_ID+".javaSource" ; //$NON-NLS-1$ >@@ -141,6 +147,111 @@ > > public HashSet optionNames = new HashSet(20); > >+ public class CompilationParticipants { >+ >+ /** Map<ICompilationParticipant, eventMask> registered by plugins */ >+ private Map pluginCPs; >+ >+ /** Map<ICompilationParticipant, eventMask> from calls to add() */ >+ private Map dynamicCPs = new HashMap(); >+ >+ /** >+ * @see JavaCore#addCompilationParticipant(ICompilationParticipant, int) >+ */ >+ public synchronized void add(ICompilationParticipant icp, int eventMask) { >+ dynamicCPs.put(icp, new Integer(eventMask)); >+ } >+ >+ /** >+ * @see JavaCore#removeCompilationParticipant(ICompilationParticipant) >+ */ >+ public synchronized void remove(ICompilationParticipant icp) { >+ dynamicCPs.remove(icp); >+ } >+ >+ /** >+ * Returns an immutable list containing the subset of registered >+ * listeners that have requested notification of at least one of >+ * the events in the flags mask. >+ * The first time this is called, it loads listeners from plugins, >+ * which may cause plugins to be loaded. If this is called on >+ * multiple threads simultaneously, or if loading a plugin causes >+ * this to be reentered, it may return an incomplete list of listeners, >+ * but it is guaranteed not to crash or deadlock. >+ * @param eventMask an ORed combination of values from ICompilationParticipant. >+ * @return an immutable list of ICompilationParticipant. >+ */ >+ public List get(int eventMask) { >+ initPlugins(); >+ List filteredICPs = new ArrayList(); >+ Iterator it; >+ synchronized(this) { >+ it = dynamicCPs.entrySet().iterator(); >+ while (it.hasNext()) { >+ Map.Entry cp = (Map.Entry)it.next(); >+ if (0 != (((Integer)cp.getValue()).intValue() | eventMask)) { >+ filteredICPs.add(cp.getKey()); >+ } >+ } >+ } >+ it = pluginCPs.entrySet().iterator(); >+ while (it.hasNext()) { >+ Map.Entry cp = (Map.Entry)it.next(); >+ if (0 != (((Integer)cp.getValue()).intValue() | eventMask)) { >+ filteredICPs.add(cp.getKey()); >+ } >+ } >+ return Collections.unmodifiableList(filteredICPs); >+ } >+ >+ private void initPlugins() { >+ synchronized (this) { >+ if (null != pluginCPs) { >+ return; >+ } >+ pluginCPs = new HashMap(); >+ } >+ IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint( >+ JavaCore.PLUGIN_ID, COMPILATION_PARTICIPANT_EXTPOINT_ID); >+ if (extension == null) >+ return; >+ IExtension[] extensions = extension.getExtensions(); >+ for(int iExtension = 0; iExtension < extensions.length; iExtension++){ >+ // for all extensions of this point... >+ for(int i = 0; i < extensions.length; i++){ >+ IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); >+ // for all config elements named "compilationParticipant" >+ for(int j = 0; j < configElements.length; j++){ >+ String elementName = configElements[j].getName(); >+ if (!("compilationParticipant".equals(elementName))) { //$NON-NLS-1$ - name of configElement >+ continue; >+ } >+ String eventMaskStr = configElements[j].getAttribute("eventMask"); //$NON-NLS-1$ - name of attribute >+ try { >+ Integer eventMask; >+ if (null != eventMaskStr) { >+ eventMask = Integer.decode(eventMaskStr); >+ } >+ else { >+ // if mask is unspecified, send it all events >+ eventMask = new Integer(-1); >+ } >+ Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$ - attribute name >+ if (execExt instanceof ICompilationParticipant){ >+ pluginCPs.put(execExt, eventMask); >+ } >+ } catch(CoreException e) { >+ // TODO: what is the right way to handle exceptions? >+ e.printStackTrace(); >+ } >+ } >+ } >+ } >+ } >+ } >+ >+ private final CompilationParticipants compilationParticipants = new CompilationParticipants(); >+ > /** > * Returns whether the given full path (for a package) conflicts with the output location > * of the given project. >@@ -856,6 +967,10 @@ > } > return container; > } >+ >+ public CompilationParticipants getCompilationParticipants() { >+ return compilationParticipants; >+ } > > public DeltaProcessor getDeltaProcessor() { > return this.deltaState.getDeltaProcessor(); >Index: model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java,v >retrieving revision 1.74 >diff -u -r1.74 AbstractImageBuilder.java >--- model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java 28 Mar 2005 13:24:26 -0000 1.74 >+++ model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java 14 Apr 2005 03:19:04 -0000 >@@ -19,6 +19,7 @@ > import org.eclipse.jdt.internal.compiler.*; > import org.eclipse.jdt.internal.compiler.ClassFile; > import org.eclipse.jdt.internal.compiler.Compiler; >+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.problem.*; > import org.eclipse.jdt.internal.compiler.util.SuffixConstants; >@@ -27,6 +28,7 @@ > import java.io.*; > import java.util.*; > >+ > /** > * The abstract superclass of Java builders. > * Provides the building and compilation mechanism >@@ -210,10 +212,80 @@ > System.arraycopy(units, i, additionalUnits, 0, additionalUnits.length); > compilingFirstGroup = false; > compile(toCompile, additionalUnits); >+ } >+ } >+} >+ >+ >+/** >+ * notify the ICompilationParticipants of the pre-build event >+ */ >+private Set notifyCompilationParticipants(ICompilationUnit[] sourceUnits) { >+ List cps = JavaCore >+ .getCompilationParticipants( ICompilationParticipant.PRE_BUILD_EVENT ); >+ if ( cps.isEmpty() ) { >+ return Collections.emptySet(); >+ } >+ >+ IFile[] files = new IFile[sourceUnits.length]; >+ for ( int i = 0; i < files.length; i++ ) { >+ if ( sourceUnits[i] instanceof SourceFile ) { >+ files[i] = ( ( SourceFile ) sourceUnits[i] ).getFile(); >+ } else { >+ String fname = new String( sourceUnits[i].getFileName() ); >+ javaBuilder.javaProject.getProject().getFile( fname ); > } > } >+ PreBuildCompilationEvent pbce = new PreBuildCompilationEvent( files, >+ javaBuilder.javaProject ); >+ >+ Set newFiles = new HashSet(); >+ java.util.Iterator it = cps.iterator(); >+ while ( it.hasNext() ) { >+ ICompilationParticipant p = ( ICompilationParticipant ) it.next(); >+ >+ CompilationParticipantResult cpr = p.notify( pbce ); >+ if ( cpr instanceof PreBuildCompilationResult ) { >+ PreBuildCompilationResult pbcr = ( PreBuildCompilationResult ) cpr; >+ >+ IFile[] f = pbcr.getNewFiles(); >+ if ( f != null ) { >+ for ( int i = 0; i < f.length; i++ ) >+ newFiles.add( f[i] ); >+ } >+ } >+ } >+ return newFiles; >+} >+ >+ >+/** >+ * given a source file, determine which of the project's source folders the file lives >+ */ >+protected ClasspathMultiDirectory getSourceLocationForFile(IFile file) { >+ ClasspathMultiDirectory md = null; >+ if ( file.exists() ) { >+ md = sourceLocations[0]; >+ if ( sourceLocations.length > 1 ) { >+ IPath sourceFileFullPath = file.getFullPath(); >+ for ( int j = 0, m = sourceLocations.length; j < m; j++ ) { >+ if ( sourceLocations[j].sourceFolder.getFullPath() >+ .isPrefixOf( sourceFileFullPath ) ) { >+ md = sourceLocations[j]; >+ if ( md.exclusionPatterns == null >+ && md.inclusionPatterns == null ) >+ break; >+ if ( !Util.isExcluded( file, md.inclusionPatterns, >+ md.exclusionPatterns ) ) >+ break; >+ } >+ } >+ } >+ } >+ return md; > } > >+ > void compile(SourceFile[] units, SourceFile[] additionalUnits) { > if (units.length == 0) return; > notifier.aboutToCompile(units[0]); // just to change the message >@@ -236,6 +308,22 @@ > notifier.checkCancel(); > try { > inCompiler = true; >+ >+ // notify compilation participants, and add any new files created >+ // by the participants into the set of files being compiled. >+ Set newFiles = notifyCompilationParticipants( units ); >+ if ( newFiles != null && newFiles.size() > 0 ) { >+ SourceFile[] newUnits = new SourceFile[units.length + newFiles.size()]; >+ System.arraycopy( units, 0, newUnits, 0, units.length ); >+ Iterator it = newFiles.iterator(); >+ int idx = units.length; >+ while ( it.hasNext() ) { >+ IFile f = ( IFile ) it.next(); >+ newUnits[idx++] = new SourceFile( f, getSourceLocationForFile( f ) ); >+ } >+ units = newUnits; >+ } >+ > compiler.compile(units); > } catch (AbortCompilation ignored) { > // ignore the AbortCompilcation coming from BuildNotifier.checkCancelWithinCompiler() >Index: model/org/eclipse/jdt/internal/core/builder/SourceFile.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SourceFile.java,v >retrieving revision 1.30 >diff -u -r1.30 SourceFile.java >--- model/org/eclipse/jdt/internal/core/builder/SourceFile.java 27 Mar 2005 23:14:02 -0000 1.30 >+++ model/org/eclipse/jdt/internal/core/builder/SourceFile.java 14 Apr 2005 03:19:06 -0000 >@@ -89,6 +89,10 @@ > return this.resource.getFullPath().toString().toCharArray(); // do not know what you want to return here > } > >+public IFile getFile() { >+ return resource; >+} >+ > public char[] getMainTypeName() { > char[] typeName = this.initialTypeName.toCharArray(); > int lastIndex = CharOperation.lastIndexOf('/', typeName); >Index: model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java,v >retrieving revision 1.29 >diff -u -r1.29 HierarchyBinaryType.java >--- model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java 23 Feb 2005 02:47:58 -0000 1.29 >+++ model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java 14 Apr 2005 03:19:06 -0000 >@@ -12,6 +12,7 @@ > > import org.eclipse.jdt.core.Signature; > import org.eclipse.jdt.core.compiler.CharOperation; >+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation; > import org.eclipse.jdt.internal.compiler.env.IBinaryField; > import org.eclipse.jdt.internal.compiler.env.IBinaryMethod; > import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType; >@@ -246,6 +247,13 @@ > /** > * @see org.eclipse.jdt.internal.compiler.env.IBinaryType > */ >+public IBinaryAnnotation[] getAnnotations() { >+ return null; >+} >+ >+/** >+ * @see org.eclipse.jdt.internal.compiler.env.IBinaryType >+ */ > public char[] sourceFileName() { > return null; > } >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java >diff -N compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,345 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.classfmt; >+ >+import org.eclipse.jdt.core.compiler.CharOperation; >+import org.eclipse.jdt.internal.compiler.ast.Annotation; >+import org.eclipse.jdt.internal.compiler.codegen.ConstantPool; >+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation; >+import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair; >+import org.eclipse.jdt.internal.compiler.lookup.TagBits; >+ >+public class AnnotationInfo extends ClassFileStruct implements IBinaryAnnotation >+{ >+ /** The name of the annotation type */ >+ private char[] typename; >+ /** number of bytes read */ >+ private int readOffset = 0; >+ /** non-null to indicate taht this annontation is initialized >+ * @see #getMemberValuePairs() >+ */ >+ private ElementValuePairInfo[] pairs; >+ private int[] constantPoolOffsets; >+ private long annoTagBits = 0; >+ /** >+ * @param classFileBytes >+ * @param offset the offset into <code>classFileBytes</code> for the >+ * "type_index" of the annotation attribute. >+ * @param populate <code>true</code> to indicate to build out the annotation structure. >+ */ >+ AnnotationInfo(byte[] classFileBytes, >+ int offset, >+ int[] contantPoolOffsets, >+ boolean runtimeVisible, >+ boolean populate) >+ { >+ super(classFileBytes, offset); >+ this.constantPoolOffsets = contantPoolOffsets; >+ this.readOffset = 0; >+ if( populate ){ >+ decodeAnnotation(); >+ } >+ else >+ this.readOffset = scanAnnotation(0, runtimeVisible, true); >+ } >+ >+ public char[] getTypeName() { >+ return this.typename; >+ } >+ >+ public IBinaryElementValuePair[] getMemberValuePairs() { >+ if( this.pairs == null ){ >+ initialize(); >+ } >+ return this.pairs; >+ } >+ >+ public long getStandardAnnotationTagBits(){ return this.annoTagBits; } >+ >+ void initialize() >+ { >+ if(this.pairs != null ) return; >+ this.readOffset = 0; >+ decodeAnnotation(); >+ } >+ >+ /** >+ * @return the length of this annotation. >+ */ >+ int getLength(){ return this.readOffset; } >+ >+ /** >+ * Read through this annotation in order to figure out the necessary tag bits and the length >+ * of this annotation. The data structure will not be flushed out. >+ * >+ * The tag bits are derived from the following (supported) standard annotation. >+ * {@link java.lang.annotation.Documented}, >+ * {@link java.lang.annotation.Retention}, >+ * {@link java.lang.annotation.Target}, and >+ * {@link java.lang.Deprecated} >+ * >+ * @param expectRuntimeVisibleAnno <code>true</cod> to indicate that this is a runtime-visible annotation >+ * @param toplevel <code>false</code> to indicate that an nested annotation is read. <code>true</code> >+ * otherwis.e >+ * @return the next offset to read. >+ */ >+ private int scanAnnotation(int offset, boolean expectRuntimeVisibleAnno, boolean toplevel) >+ { >+ int curOffset = offset; >+ int utf8Offset = this.constantPoolOffsets[u2At(offset)] - structOffset; >+ char[] typeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ if(toplevel) >+ this.typename = typeName; >+ int numberOfPairs = u2At(offset + 2); >+ // u2 type_index + u2 number_member_value_pair >+ curOffset += 4; >+ if(expectRuntimeVisibleAnno && toplevel){ >+ switch(typeName.length) { >+ case 21 : >+ if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_INHERITED)) { >+ this.annoTagBits |= TagBits.AnnotationInherited; >+ return curOffset; >+ } >+ break; >+ case 22 : >+ if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_DEPRECATED)) { >+ this.annoTagBits |= TagBits.AnnotationDeprecated; >+ return curOffset; >+ } >+ break; >+ case 29 : >+ if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_TARGET)) { >+ curOffset += 2; >+ return readTargetValue(curOffset); >+ } >+ break; >+ case 33 : >+ if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_DOCUMENTED)) { >+ this.annoTagBits |= TagBits.AnnotationDocumented; >+ return curOffset; >+ } >+ break; >+ case 32 : >+ if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_RETENTION)) { >+ curOffset += 2; >+ return readRetentionPolicy(curOffset); >+ } >+ break; >+ } >+ } >+ for (int i = 0; i < numberOfPairs; i++) { >+ // u2 member_name_index >+ curOffset += 2; >+ curOffset = scanElementValue(curOffset); >+ } >+ return curOffset; >+ } >+ >+ /** >+ * @param offset the offset to start reading. >+ * @return the next offset to read. >+ */ >+ private int scanElementValue(int offset) { >+ int curOffset = offset; >+ int tag = u1At(curOffset); >+ curOffset++; >+ switch(tag) { >+ case 'B' : >+ case 'C' : >+ case 'D' : >+ case 'F' : >+ case 'I' : >+ case 'J' : >+ case 'S' : >+ case 'Z' : >+ case 's' : >+ curOffset += 2; >+ break; >+ case 'e' : >+ curOffset += 4; >+ break; >+ case 'c' : >+ curOffset += 2; >+ break; >+ case '@' : >+ // none of the supported standard annotation are in the nested level. >+ curOffset = scanAnnotation(curOffset, false, false); >+ break; >+ case '[' : >+ int numberOfValues = u2At(curOffset); >+ curOffset += 2; >+ for (int i = 0; i < numberOfValues; i++) { >+ curOffset = scanElementValue(curOffset); >+ } >+ break; >+ default: >+ throw new IllegalStateException(); >+ } >+ return curOffset; >+ } >+ >+ private int readRetentionPolicy(int offset) { >+ int curOffset = offset; >+ int tag = u1At(curOffset); >+ curOffset++; >+ switch(tag) { >+ case 'e' : >+ int utf8Offset = this.constantPoolOffsets[u2At(curOffset)] - structOffset; >+ char[] typeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ curOffset += 2; >+ utf8Offset = this.constantPoolOffsets[u2At(curOffset)]- structOffset; >+ char[] constName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ curOffset += 2; >+ if (typeName.length == 38 && CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_RETENTIONPOLICY)) >+ this.annoTagBits |= Annotation.getRetentionPolicy(constName); >+ break; >+ case 'B' : >+ case 'C' : >+ case 'D' : >+ case 'F' : >+ case 'I' : >+ case 'J' : >+ case 'S' : >+ case 'Z' : >+ case 's' : >+ curOffset += 2; >+ break; >+ case 'c' : >+ curOffset += 2; >+ break; >+ case '@' : >+ // none of the supported standard annotation are in the nested level. >+ curOffset = scanAnnotation(curOffset, false, false); >+ break; >+ case '[' : >+ int numberOfValues = u2At(curOffset); >+ curOffset += 2; >+ for (int i = 0; i < numberOfValues; i++) { >+ curOffset = scanElementValue(curOffset); >+ } >+ break; >+ default: >+ throw new IllegalStateException(); >+ } >+ return curOffset; >+ } >+ >+ private int readTargetValue(int offset) >+ { >+ int curOffset = offset; >+ int tag = u1At(curOffset); >+ curOffset++; >+ switch(tag) { >+ case 'e' : >+ int utf8Offset = this.constantPoolOffsets[u2At(curOffset)] - structOffset; >+ char[] typeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ curOffset += 2; >+ utf8Offset = this.constantPoolOffsets[u2At(curOffset)] - structOffset; >+ char[] constName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ curOffset += 2; >+ if (typeName.length == 34 && CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_ELEMENTTYPE)) { >+ this.annoTagBits |= Annotation.getTargetElementType(constName); >+ } >+ break; >+ >+ case 'B' : >+ case 'C' : >+ case 'D' : >+ case 'F' : >+ case 'I' : >+ case 'J' : >+ case 'S' : >+ case 'Z' : >+ case 's' : >+ curOffset += 2; >+ break; >+ case 'c' : >+ curOffset += 2; >+ break; >+ case '@' : >+ // none of the supported standard annotation are in the nested level. >+ curOffset = scanAnnotation(curOffset, false, false); >+ break; >+ case '[' : >+ int numberOfValues = u2At(curOffset); >+ curOffset += 2; >+ if (numberOfValues == 0) { >+ this.annoTagBits |= TagBits.AnnotationTarget; >+ } >+ else { >+ for (int i = 0; i < numberOfValues; i++) { >+ curOffset = readTargetValue(curOffset); >+ } >+ } >+ break; >+ default: >+ throw new IllegalStateException(); >+ } >+ return curOffset; >+ } >+ >+ /** >+ * Flush out the annotation data structure. >+ */ >+ private void decodeAnnotation() >+ { >+ int utf8Offset = this.constantPoolOffsets[u2At(0)] - structOffset; >+ this.typename = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ int numberOfPairs = u2At(2); >+ // u2 type_index + u2 num_member_value_pair >+ this.readOffset += 4; >+ if( numberOfPairs == 0 ) >+ this.pairs = ElementValuePairInfo.NoMember; >+ else >+ this.pairs = new ElementValuePairInfo[numberOfPairs]; >+ >+ for (int i = 0; i < numberOfPairs; i++) { >+ this.pairs[i] = decodePair(); >+ } >+ } >+ >+ private ElementValuePairInfo decodePair() >+ { >+ // u2 member_name_index; >+ int utf8Offset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ char[] membername = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ this.readOffset += 2; >+ final ElementValueInfo elementValue = new ElementValueInfo(this.reference, this.constantPoolOffsets, >+ this.readOffset + this.structOffset); >+ final Object value = elementValue.decodeValue(); >+ this.readOffset += elementValue.getLength(); >+ return new ElementValuePairInfo(membername, value); >+ } >+ >+ protected void reset() { >+ this.constantPoolOffsets = null; >+ super.reset(); >+ } >+ >+ public String toString() >+ { >+ StringBuilder buffer = new StringBuilder(); >+ buffer.append('@'); >+ buffer.append(this.typename); >+ if(this.pairs != null){ >+ buffer.append('('); >+ buffer.append("\n\t"); //$NON-NLS-1$ >+ for( int i=0, len = this.pairs.length; i<len; i++ ){ >+ if( i > 0 ) >+ buffer.append(",\n\t"); //$NON-NLS-1$ >+ buffer.append(this.pairs[i]); >+ } >+ buffer.append(')'); >+ } >+ >+ return buffer.toString(); >+ } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfo.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfo.java >diff -N compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,79 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.classfmt; >+ >+import org.eclipse.jdt.core.compiler.CharOperation; >+ >+public class AnnotationMethodInfo extends MethodInfo >+{ >+ private Object defaultValue = null; >+ AnnotationMethodInfo(byte classFileBytes[], int constantPoolOffsets[], int offset) >+ { >+ super(classFileBytes, constantPoolOffsets, offset); >+ readAttributes(); >+ } >+ >+ private void readAttributes() >+ { >+ int attributesCount = u2At(6); >+ int readOffset = 8; >+ for (int i = 0; i < attributesCount; i++) { >+ // check the name of each attribute >+ int utf8Offset = constantPoolOffsets[u2At(readOffset)] - structOffset; >+ char[] attributeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ if (attributeName.length > 0) { >+ switch(attributeName[0]) { >+ case 'A' : >+ if(CharOperation.equals(attributeName, AnnotationDefaultName)){ >+ decodeDefaultValue(readOffset); >+ } >+ break; >+ } >+ } >+ readOffset += (6 + u4At(readOffset + 2)); >+ } >+ } >+ >+ private void decodeDefaultValue( int offset ) >+ { >+ // offset + 6 so the offset is at the start of the 'member_value' entry >+ // u2 attribute_name_index + u4 attribute_length = + 6 >+ final ElementValueInfo defaultValueInfo = >+ new ElementValueInfo(this.reference, this.constantPoolOffsets, offset + 6 + this.structOffset ); >+ this.defaultValue = defaultValueInfo.decodeValue(); >+ } >+ >+ public Object getDefaultValue(){ return this.defaultValue; } >+ >+ public String toString() >+ { >+ final StringBuilder buffer = new StringBuilder(); >+ toString(buffer); >+ if( this.defaultValue != null ) >+ { >+ buffer.append(" default "); //$NON-NLS-1$ >+ if( this.defaultValue instanceof Object[] ) >+ { >+ buffer.append('{'); >+ final Object[] elements = (Object[])this.defaultValue; >+ for( int i=0, len = elements.length; i<len; i++ ){ >+ if( i > 0 ) >+ buffer.append(", "); //$NON-NLS-1$ >+ buffer.append(elements[i]); >+ } >+ buffer.append('}'); >+ } >+ else >+ buffer.append(this.defaultValue); >+ } >+ return buffer.toString(); >+ } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassReference.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassReference.java >diff -N compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassReference.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassReference.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.classfmt; >+ >+import org.eclipse.jdt.internal.compiler.env.IClassReference; >+ >+public class ClassReference implements IClassReference >+{ >+ private final char[] className; >+ ClassReference(final char[] className) >+ { >+ this.className = className; >+ } >+ >+ public char[] getTypeName(){ return this.className; } >+ public String toString() >+ { >+ StringBuilder buffer = new StringBuilder(); >+ buffer.append(this.className); >+ buffer.append(".class"); //$NON-NLS-1$ >+ return buffer.toString(); >+ } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValueInfo.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValueInfo.java >diff -N compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValueInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValueInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,146 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.classfmt; >+ >+import org.eclipse.jdt.internal.compiler.impl.BooleanConstant; >+import org.eclipse.jdt.internal.compiler.impl.ByteConstant; >+import org.eclipse.jdt.internal.compiler.impl.CharConstant; >+import org.eclipse.jdt.internal.compiler.impl.DoubleConstant; >+import org.eclipse.jdt.internal.compiler.impl.FloatConstant; >+import org.eclipse.jdt.internal.compiler.impl.IntConstant; >+import org.eclipse.jdt.internal.compiler.impl.LongConstant; >+import org.eclipse.jdt.internal.compiler.impl.ShortConstant; >+import org.eclipse.jdt.internal.compiler.impl.StringConstant; >+ >+/** >+ * This is a transitional object for decoding a element value of an annotation >+ * and default value of a annotation method. >+ */ >+public class ElementValueInfo extends ClassFileStruct >+{ >+ private int readOffset = 0; >+ private int[] constantPoolOffsets; >+ private Object value = null; >+ >+ ElementValueInfo(final byte[] classFileBytes, >+ final int[] constantPoolOffsets, >+ final int absoluteOffset) >+ { >+ super(classFileBytes, absoluteOffset); >+ this.constantPoolOffsets = constantPoolOffsets; >+ } >+ >+ /** >+ * @return the length of this annotation. >+ */ >+ int getLength(){ return this.readOffset; } >+ >+ Object decodeValue() >+ { >+ // u1 tag; >+ int tag = u1At(this.readOffset); >+ this.readOffset++; >+ int constValueOffset = -1; >+ switch(tag) { >+ case 'Z' : // boolean constant >+ constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ this.value = new BooleanConstant(i4At(constValueOffset+1) == 1); >+ this.readOffset += 2; >+ break; >+ case 'I' : // integer constant >+ constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ this.value = new IntConstant(i4At(constValueOffset+1)); >+ this.readOffset += 2; >+ break; >+ case 'C' : // char constant >+ constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ this.value = new CharConstant((char)i4At(constValueOffset+1)); >+ this.readOffset += 2; >+ break; >+ case 'B' : // byte constant >+ constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ this.value = new ByteConstant((byte) i4At(constValueOffset+1)); >+ this.readOffset += 2; >+ break; >+ case 'S' : // short constant >+ constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ this.value = new ShortConstant((short) i4At(constValueOffset+1)); >+ this.readOffset += 2; >+ break; >+ case 'D' : // double constant >+ constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ this.value = new DoubleConstant(doubleAt(constValueOffset+1)); >+ this.readOffset += 2; >+ break; >+ case 'F' : // float constant >+ constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ this.value = new FloatConstant(floatAt(constValueOffset+1)); >+ this.readOffset += 2; >+ break; >+ case 'J' : // long constant >+ constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ this.value = new LongConstant(i8At(constValueOffset+1)); >+ this.readOffset += 2; >+ break; >+ case 's' : // String >+ { >+ int utf8Offset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ this.value = new StringConstant( >+ String.valueOf(utf8At(utf8Offset + 3, u2At(utf8Offset + 1)))); >+ this.readOffset += 2; >+ break; >+ } >+ case 'e' : >+ { >+ int utf8Offset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ char[] typeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ this.readOffset += 2; >+ utf8Offset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ char[] constName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ this.readOffset += 2; >+ this.value = new EnumReference(typeName, constName); >+ break; >+ } >+ case 'c' : >+ { >+ int utf8Offset = this.constantPoolOffsets[u2At(this.readOffset)] - structOffset; >+ char[] className = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); >+ this.value = new ClassReference(className); >+ this.readOffset += 2; >+ break; >+ } >+ case '@' : >+ this.value = new AnnotationInfo(reference, this.readOffset + structOffset, this.constantPoolOffsets, false, true); >+ this.readOffset += ((AnnotationInfo)value).getLength(); >+ break; >+ case '[' : >+ int numberOfValues = u2At(this.readOffset); >+ this.readOffset += 2; >+ if( numberOfValues == 0 ) >+ this.value = ElementValuePairInfo.ZeroLengthArray; >+ else{ >+ Object[] arrayElements = new Object[numberOfValues]; >+ this.value = arrayElements; >+ for (int i = 0; i < numberOfValues; i++) { >+ final ElementValueInfo elementValue = new ElementValueInfo(this.reference, this.constantPoolOffsets, >+ this.readOffset + this.structOffset); >+ arrayElements[i] = elementValue.decodeValue(); >+ this.readOffset += elementValue.getLength(); >+ } >+ } >+ break; >+ default: >+ throw new IllegalStateException("Unrecognized tag " + (char)tag); //$NON-NLS-1$ >+ >+ } >+ return this.value; >+ } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java >diff -N compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.classfmt; >+ >+import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair; >+ >+public class ElementValuePairInfo implements IBinaryElementValuePair >+{ >+ static final ElementValuePairInfo[] NoMember = new ElementValuePairInfo[0]; >+ static final Object[] ZeroLengthArray = new Object[0]; >+ private final char[] _membername; >+ private final Object _value; >+ >+ ElementValuePairInfo(char[] membername, Object value) >+ { >+ _membername = membername; >+ _value = value; >+ } >+ >+ public char[] getMemberName() { return _membername; } >+ >+ public Object getMemberValue() { return _value; } >+ >+ public String toString() >+ { >+ StringBuilder buffer = new StringBuilder(); >+ buffer.append(_membername); >+ buffer.append('='); >+ if( _value instanceof Object[] ){ >+ final Object[] values = (Object[])_value; >+ buffer.append('{'); >+ for( int i=0, len=values.length; i<len; i++ ){ >+ if( i > 0 ) >+ buffer.append(", "); >+ buffer.append(values[i]); >+ } >+ buffer.append('}'); >+ } >+ else >+ buffer.append(_value); >+ return buffer.toString(); >+ } >+ >+ >+ >+} >Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/EnumReference.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/classfmt/EnumReference.java >diff -N compiler/org/eclipse/jdt/internal/compiler/classfmt/EnumReference.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/classfmt/EnumReference.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.classfmt; >+ >+import org.eclipse.jdt.internal.compiler.env.IEnumConstantReference; >+ >+/** >+ * Represents a reference to the enum constant in a class file. >+ */ >+public class EnumReference implements IEnumConstantReference >+{ >+ /** type name of the enum type */ >+ private final char[] typeName; >+ /** name of the enum constant */ >+ private final char[] constName; >+ >+ EnumReference(final char[] typeName, char[] constName) >+ { >+ this.typeName = typeName; >+ this.constName = constName; >+ } >+ >+ public char[] getTypeName(){ return this.typeName; } >+ public char[] getEnumConstantName(){ return this.constName; } >+ >+ public String toString() >+ { >+ StringBuilder buffer = new StringBuilder(); >+ buffer.append(this.typeName); >+ buffer.append('.'); >+ buffer.append(this.constName); >+ return buffer.toString(); >+ } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/env/IBinaryAnnotation.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/env/IBinaryAnnotation.java >diff -N compiler/org/eclipse/jdt/internal/compiler/env/IBinaryAnnotation.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/env/IBinaryAnnotation.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.jdt.internal.compiler.env; >+ >+ >+/** >+ * This represents class file information about an annotation instance. >+ */ >+public interface IBinaryAnnotation >+{ >+ public static final IBinaryAnnotation[] NoAnnotation = new IBinaryAnnotation[0]; >+ public static final IBinaryElementValuePair[] NoMemberValuePair = new IBinaryElementValuePair[0]; >+ >+ /** >+ * @return the fully qualified name of the annotation type. >+ */ >+ char[] getTypeName(); >+ >+ /** >+ * @return the list of member value pairs of the annotation >+ */ >+ IBinaryElementValuePair[] getMemberValuePairs(); >+} >Index: compiler/org/eclipse/jdt/internal/compiler/env/IBinaryAnnotationMethod.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/env/IBinaryAnnotationMethod.java >diff -N compiler/org/eclipse/jdt/internal/compiler/env/IBinaryAnnotationMethod.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/env/IBinaryAnnotationMethod.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.env; >+ >+/** >+ * Method of an annotation type; >+ */ >+public interface IBinaryAnnotationMethod >+{ >+ /** >+ * Return {@link org.eclipse.jdt.internal.compiler.impl.Constant} for compile-time >+ * constant of primitive type, as well as String literals. >+ * Return {@link IEnumConstantReference} if value is an enum constant >+ * Return {@link IBinaryAnnotation} for annotation type. >+ * Return {@link IClassReference} for member of type {@link java.lang.Class}. >+ * Return {@link Object}[] for array type. >+ * @return default value of this annotation method >+ */ >+ Object getDefaultValue(); >+} >Index: compiler/org/eclipse/jdt/internal/compiler/env/IBinaryElementValuePair.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/env/IBinaryElementValuePair.java >diff -N compiler/org/eclipse/jdt/internal/compiler/env/IBinaryElementValuePair.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/env/IBinaryElementValuePair.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,23 @@ >+package org.eclipse.jdt.internal.compiler.env; >+ >+ >+/** >+ * This represents the class file information about a member value pair of an annotaiton. >+ */ >+public interface IBinaryElementValuePair >+{ >+ /** @return the name of the member */ >+ char[] getMemberName(); >+ >+ /** >+ * Return {@link org.eclipse.jdt.internal.compiler.impl.Constant} for compile-time >+ * constant of primitive type, as well as String literals. >+ * Return {@link IEnumConstantReference} if value is an enum constant >+ * Return {@link IBinaryAnnotation} for annotation type. >+ * Return {@link IClassReference} for member of type {@link java.lang.Class}. >+ * Return {@link Object}[] for array type. >+ * @return the value of this member value pair >+ */ >+ Object getMemberValue(); >+ >+} >Index: compiler/org/eclipse/jdt/internal/compiler/env/IClassReference.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/env/IClassReference.java >diff -N compiler/org/eclipse/jdt/internal/compiler/env/IClassReference.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/env/IClassReference.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,10 @@ >+package org.eclipse.jdt.internal.compiler.env; >+ >+/** >+ * Represents a class reference in the class file. >+ */ >+public interface IClassReference >+{ >+ /** @return the name of the type reference */ >+ char[] getTypeName(); >+} >Index: compiler/org/eclipse/jdt/internal/compiler/env/IEnumConstantReference.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/env/IEnumConstantReference.java >diff -N compiler/org/eclipse/jdt/internal/compiler/env/IEnumConstantReference.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/env/IEnumConstantReference.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,17 @@ >+package org.eclipse.jdt.internal.compiler.env; >+ >+/** >+ * Represents a reference to a enum constant in the class file >+ */ >+public interface IEnumConstantReference >+{ >+ /** >+ * @return name of the enum type in the class file format >+ */ >+ char[] getTypeName(); >+ >+ /** >+ * @return the name of the enum constant reference. >+ */ >+ char[] getEnumConstantName(); >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationInstance.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationInstance.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationInstance.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationInstance.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,27 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+/** >+ * Represents JSR 175 Annotation instances in the type-system. >+ */ >+public interface AnnotationInstance{ >+ >+ /** >+ * @return the annotation type of this instance. >+ */ >+ ReferenceBinding getAnnotationType(); >+ >+ /** >+ * @return the declared element value pairs of this instance. >+ */ >+ ElementValuePair[] getElementValuePairs(); >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationMethodBinding.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationMethodBinding.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationMethodBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationMethodBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+/** >+ * Annotation method that came from binary. >+ * @author tyeung >+ * >+ */ >+public class AnnotationMethodBinding extends BinaryMethodBinding >+{ >+ private Object defaultValue; >+ public AnnotationMethodBinding(int modifiers, >+ char[] selector, >+ TypeBinding returnType, >+ ReferenceBinding declaringClass, >+ AnnotationInstance[] methodAnnotation, >+ AnnotationInstance[][] parameterAnnotations, >+ Object defaultValue) >+ { >+ super(modifiers, selector, >+ returnType, NoParameters, >+ NoExceptions, declaringClass, >+ methodAnnotation, parameterAnnotations ); >+ >+ this.defaultValue = defaultValue; >+ } >+ >+ public Object getDefaultValue() >+ { >+ return this.defaultValue; >+ } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryAnnotation.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryAnnotation.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryAnnotation.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryAnnotation.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+/** >+ * JSR 175 Annotation instances that came from binary >+ */ >+public class BinaryAnnotation implements AnnotationInstance >+{ >+ // At creation the type may not be fully resolved. >+ // The type will become fully resolved when this annotation is requested. >+ ReferenceBinding typeBinding; >+ ElementValuePair[] pairs; >+ private final LookupEnvironment env; >+ >+ BinaryAnnotation(ReferenceBinding binding, LookupEnvironment env) >+ { >+ this.typeBinding = binding; >+ this.pairs = null; >+ this.env = env; >+ } >+ >+ public ReferenceBinding getAnnotationType() >+ { >+ // annotation type are never parameterized >+ return BinaryTypeBinding.resolveType(this.typeBinding, this.env, false); >+ } >+ >+ public ElementValuePair[] getElementValuePairs(){ return this.pairs; } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryElementValuePair.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryElementValuePair.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryElementValuePair.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryElementValuePair.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,61 @@ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+public class BinaryElementValuePair implements ElementValuePair >+{ >+ //The annotation that directly contains this value pair. >+ private final BinaryAnnotation anno; >+ private final char[] membername; >+ private final Object value; >+ >+ BinaryElementValuePair(final BinaryAnnotation anno, final char[] membername, final Object value) >+ { >+ this.anno = anno; >+ this.membername = membername; >+ this.value = value; >+ } >+ >+ public char[] getMemberName() >+ { return membername; } >+ >+ /** >+ * @return the method binding that defined this member value pair or null >+ * if no such binding exists. >+ */ >+ public MethodBinding getMethodBinding() >+ { >+ final ReferenceBinding typeBinding = anno.getAnnotationType(); >+ if( typeBinding != null ){ >+ final MethodBinding[] methods = typeBinding.getMethods(this.membername); >+ // there should be exactly one since the type is an annotation type. >+ if( methods != null && methods.length == 1) >+ return methods[0]; >+ } >+ return null; >+ } >+ >+ /** >+ * Convinence method. >+ * The type will determine the type of objects returned from {@link #getValue()} >+ * @return the type of the member value or null if it cannot be determined >+ * @see #getMethodBinding() >+ * @see #getValue() >+ * >+ */ >+ public TypeBinding getType() >+ { >+ final MethodBinding method = getMethodBinding(); >+ return method == null ? null : method.returnType; >+ } >+ >+ /** >+ * <br><li>Return {@link TypeBinding} for member value of type {@link java.lang.Class}</li></br> >+ * <br><li>Return {@link org.eclipse.jdt.internal.compiler.impl.Constant} >+ * for member of primitive type or String</li></br> >+ * <br><li>Return {@link FieldBinding} for enum constant</li></br> >+ * <br><li>Return {@link AnnotationInstance} for annotation instance</li></br> >+ * <br><li>Return <code>Object[]</code> for member value of array type. >+ * @return the value of this member value pair or null if the value is missing or >+ * is not a compile-time constant. >+ */ >+ public Object getValue(){ return this.value; } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryFieldBinding.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryFieldBinding.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryFieldBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryFieldBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; >+import org.eclipse.jdt.internal.compiler.impl.Constant; >+ >+public class BinaryFieldBinding extends FieldBinding >+{ >+ private AnnotationInstance[] annotations = NoAnnotations; >+ public BinaryFieldBinding(char[] name, >+ TypeBinding type, >+ int modifiers, >+ ReferenceBinding declaringClass, >+ Constant constant, >+ AnnotationInstance[] annos) { >+ super(name, type, modifiers, declaringClass, constant); >+ if( annos != null ) >+ this.annotations = annos; >+ } >+ >+ public BinaryFieldBinding(BinaryFieldBinding initialFieldBinding, ReferenceBinding declaringClass) >+ { >+ super(initialFieldBinding, declaringClass); >+ this.annotations = initialFieldBinding.annotations; >+ } >+ >+ public AnnotationInstance[] getAnnotations() >+ { >+ return annotations; >+ } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryMethodBinding.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryMethodBinding.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryMethodBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryMethodBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,108 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+public class BinaryMethodBinding extends MethodBinding >+{ >+ private static final AnnotationInstance[][] NoMethodAnnotation = new AnnotationInstance[][]{ NoAnnotations }; >+ private static final AnnotationInstance[][] NoExtendedModifiers = new AnnotationInstance[0][]; >+ >+ /** >+ * In the majority of the time, there will no annotations at all. >+ * We will try to optimized the storage by packing both >+ * method and parameter annotation into one field. >+ * >+ * If there are no annotations and no parameter annotations, >+ * this will be a zero-length array. >+ * If this is an array of size 1, then method annotations are intialized and there >+ * may or may not be parameter annotations. >+ * If there are ever any parameter annotations, this will be an array of size > 1. >+ * </code>null</code> in the array means not initialized. >+ * If the field is <code>null</code> this means it is not initalized at all. >+ */ >+ private AnnotationInstance[][] extendedModifiers = null; >+ >+ public BinaryMethodBinding(int modifiers, >+ char[] selector, >+ TypeBinding returnType, >+ TypeBinding[] parameters, >+ ReferenceBinding[] thrownExceptions, >+ ReferenceBinding declaringClass, >+ AnnotationInstance[] methodAnnotations, >+ AnnotationInstance[][] parameterAnnotations) >+ { >+ super( modifiers, selector, returnType, parameters, thrownExceptions, declaringClass); >+ } >+ >+ //constructor for creating binding representing constructor >+ public BinaryMethodBinding(int modifiers, >+ TypeBinding[] parameters, >+ ReferenceBinding[] thrownExceptions, >+ ReferenceBinding declaringClass, >+ AnnotationInstance[] methodAnnotations, >+ AnnotationInstance[][] parameterAnnotations) >+ { >+ this(modifiers, TypeConstants.INIT, VoidBinding, >+ parameters, thrownExceptions, declaringClass, >+ methodAnnotations, parameterAnnotations); >+ } >+ >+ >+ //special API used to change method declaring class for runtime visibility check >+ public BinaryMethodBinding(BinaryMethodBinding initialMethodBinding, ReferenceBinding declaringClass) >+ { >+ super(initialMethodBinding, declaringClass ); >+ this.extendedModifiers = initialMethodBinding.extendedModifiers; >+ } >+ >+ void initExtendedModifiers(final AnnotationInstance[] methodAnnotations, >+ final AnnotationInstance[][] parameterAnnotations) >+ { >+ final int numMethodAnnos = methodAnnotations.length; >+ final int numParams = parameterAnnotations.length; >+ if( numMethodAnnos == 0 && numParams == 0 ) >+ this.extendedModifiers = NoExtendedModifiers; >+ else{ >+ // not even going to create the slot if there are no parameters >+ if( numParams == 0 ) >+ this.extendedModifiers = new AnnotationInstance[][]{methodAnnotations}; >+ else{ >+ this.extendedModifiers = new AnnotationInstance[numParams + 1][]; >+ this.extendedModifiers[0] = methodAnnotations; >+ System.arraycopy(parameterAnnotations, 0, this.extendedModifiers, 1, numParams); >+ } >+ } >+ } >+ >+ public AnnotationInstance[] getAnnotations() >+ { >+ final int len = this.extendedModifiers.length; >+ if( len == 0 ) return NoAnnotations; >+ else >+ return this.extendedModifiers[0]; >+ } >+ >+ public AnnotationInstance[] getParameterAnnotations(final int index) >+ { >+ final int numberOfParameters = this.parameters == null ? 0 : this.parameters.length; >+ if( numberOfParameters == 0 || index < 0 || index >= numberOfParameters ) >+ throw new IllegalArgumentException("number of parameters = " + numberOfParameters + //$NON-NLS-1$ >+ " index = " + index ); //$NON-NLS-1$ >+ final int numberOfExtendedMods = this.extendedModifiers.length; >+ // no annotations what so ever. >+ if( numberOfExtendedMods == 0 ) >+ return NoAnnotations; >+ else >+ return this.extendedModifiers[index + 1]; >+ } >+ >+ public Object getDefaultValue(){ return null; } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ElementValuePair.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+public interface ElementValuePair >+{ >+ /** >+ * @return the name of the member. >+ */ >+ >+ char[] getMemberName(); >+ /** >+ * @return the method binding that defined this member value pair or null >+ * if no such binding exists. >+ */ >+ MethodBinding getMethodBinding(); >+ >+ /** >+ * Convinence method. >+ * The type will determine the type of objects returned from {@link #getValue()} >+ * @return the type of the member value or null if it cannot be determined >+ * @see #getMethodBinding() >+ * @see #getValue() >+ * >+ */ >+ TypeBinding getType(); >+ >+ /** >+ * <br><li>Return {@link TypeBinding} for member value of type {@link java.lang.Class}</li></br> >+ * <br><li>Return {@link org.eclipse.jdt.internal.compiler.impl.Constant} >+ * for member of primitive type or String</li></br> >+ * <br><li>Return {@link FieldBinding} for enum constant</li></br> >+ * <br><li>Return {@link AnnotationInstance} for annotation instance</li></br> >+ * <br><li>Return <code>Object[]</code> for member value of array type. >+ * @return the value of this member value pair or null if the value is missing or >+ * is not a compile-time constant. >+ */ >+ Object getValue(); >+ >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceAnnotation.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceAnnotation.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/SourceAnnotation.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceAnnotation.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+import org.eclipse.jdt.internal.compiler.ast.Annotation; >+import org.eclipse.jdt.internal.compiler.ast.MemberValuePair; >+ >+/** >+ * Annotation that came from source. >+ * @author tyeung >+ * >+ */ >+public class SourceAnnotation implements AnnotationInstance, TypeConstants >+{ >+ private final Annotation astAnnotation; >+ private final ElementValuePair[] pairs; >+ >+ public SourceAnnotation(Annotation astAnnotation) >+ { >+ this.astAnnotation = astAnnotation; >+ final MemberValuePair[] astPairs = astAnnotation.memberValuePairs(); >+ int numberOfPairs = astPairs == null ? 0 : astPairs.length; >+ if( numberOfPairs == 0 ) >+ this.pairs = NoElementValuePairs; >+ else{ >+ this.pairs = new SourceElementValuePair[numberOfPairs]; >+ for( int i=0; i<numberOfPairs; i++ ){ >+ this.pairs[i] = new SourceElementValuePair(astPairs[i]); >+ } >+ } >+ } >+ >+ public ReferenceBinding getAnnotationType() { >+ return (ReferenceBinding)this.astAnnotation.resolvedType; >+ } >+ >+ public ElementValuePair[] getElementValuePairs() { return this.pairs; } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceElementValuePair.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceElementValuePair.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/SourceElementValuePair.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceElementValuePair.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,68 @@ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+import org.eclipse.jdt.internal.compiler.ast.Annotation; >+import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer; >+import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; >+import org.eclipse.jdt.internal.compiler.ast.Expression; >+import org.eclipse.jdt.internal.compiler.ast.MemberValuePair; >+import org.eclipse.jdt.internal.compiler.impl.Constant; >+ >+public class SourceElementValuePair implements ElementValuePair >+{ >+ private final MemberValuePair astPair; >+ private Object value = null; >+ >+ SourceElementValuePair(final MemberValuePair pair) >+ { >+ this.astPair = pair; >+ } >+ >+ public char[] getMemberName() >+ { return this.astPair.name; } >+ >+ public MethodBinding getMethodBinding() { >+ return this.astPair.binding; >+ } >+ >+ public TypeBinding getType() { >+ if(this.astPair.binding == null) return null; >+ return this.astPair.binding.returnType; >+ } >+ >+ public Object getValue() { >+ if( this.value != null ) return this.value; >+ >+ final Expression expression = this.astPair.value; >+ this.value = getValue(expression); >+ return this.value; >+ } >+ >+ static Object getValue(Expression expression) >+ { >+ if( expression == null ) return null; >+ Constant constant = expression.constant; >+ // literals would hit this case. >+ if( constant != null ) return constant; >+ >+ if( expression instanceof Annotation ) >+ return new SourceAnnotation( (Annotation)expression ); >+ >+ else if( expression instanceof ArrayInitializer ) >+ { >+ final Expression[] exprs = ((ArrayInitializer)expression).expressions; >+ int len = exprs == null ? 0 : exprs.length; >+ final Object[] values = new Object[len]; >+ for( int i=0; i<len; i++ ) >+ values[i] = getValue(exprs[i]); >+ return values; >+ } >+ else if( expression instanceof ClassLiteralAccess ) >+ { >+ final ClassLiteralAccess classLiteral = (ClassLiteralAccess)expression; >+ return classLiteral.targetType; >+ } >+ // something that isn't a compile time constant. >+ else >+ return null; >+ } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceFieldBinding.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceFieldBinding.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/SourceFieldBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceFieldBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+import org.eclipse.jdt.internal.compiler.ast.Annotation; >+import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; >+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; >+import org.eclipse.jdt.internal.compiler.impl.Constant; >+ >+public class SourceFieldBinding extends FieldBinding >+{ >+ public SourceFieldBinding(char[] name, >+ TypeBinding type, >+ int modifiers, >+ ReferenceBinding declaringClass, >+ Constant constant){ >+ super(name, type, modifiers, declaringClass, constant); >+ } >+ >+ public SourceFieldBinding(FieldDeclaration field, >+ TypeBinding type, >+ int modifiers, >+ ReferenceBinding declaringClass) { >+ this(field.name, type, modifiers, declaringClass, null); >+ field.binding = this; // record binding in declaration >+ } >+ >+ public SourceFieldBinding(SourceFieldBinding initialFieldBinding, ReferenceBinding declaringClass) >+ { >+ super(initialFieldBinding, declaringClass); >+ } >+ >+ public AnnotationInstance[] getAnnotations() { >+ // make sure we check the annotations for problems >+ getAnnotationTagBits(); >+ AnnotationInstance[] result = NoAnnotations; >+ // length field of an array don't have a declaring class. >+ if( this.declaringClass != null ){ >+ TypeDeclaration typeDecl = ((SourceTypeBinding)this.declaringClass).scope.referenceContext; >+ FieldDeclaration fieldDecl = typeDecl.declarationOf(this); >+ >+ if (fieldDecl != null){ >+ final Annotation[] fieldAnnos = fieldDecl.annotations; >+ final int len = fieldAnnos == null ? 0 : fieldAnnos.length; >+ if( len > 0 ) >+ { >+ result = new AnnotationInstance[len]; >+ for( int i = 0; i < len; i++ ){ >+ result[i] = fieldAnnos[i].compilerAnnotation; >+ } >+ } >+ } >+ } >+ return result; >+ } >+} >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceMethodBinding.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceMethodBinding.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/SourceMethodBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceMethodBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+import org.eclipse.jdt.internal.compiler.ast.ASTNode; >+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; >+import org.eclipse.jdt.internal.compiler.ast.Annotation; >+import org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration; >+import org.eclipse.jdt.internal.compiler.ast.Argument; >+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; >+ >+public class SourceMethodBinding extends MethodBinding >+{ >+ public SourceMethodBinding(int modifiers, >+ char[] selector, >+ TypeBinding returnType, >+ TypeBinding[] parameters, >+ ReferenceBinding[] thrownExceptions, >+ ReferenceBinding declaringClass) >+ { >+ super( modifiers, selector, returnType, parameters, thrownExceptions, declaringClass); >+ } >+ >+ //constructor for creating binding representing constructor >+ public SourceMethodBinding(int modifiers, >+ TypeBinding[] parameters, >+ ReferenceBinding[] thrownExceptions, >+ ReferenceBinding declaringClass) >+ { >+ this(modifiers, TypeConstants.INIT, VoidBinding, parameters, thrownExceptions, declaringClass); >+ } >+ >+ >+ //special API used to change method declaring class for runtime visibility check >+ public SourceMethodBinding(SourceMethodBinding initialMethodBinding, ReferenceBinding declaringClass) >+ { >+ super(initialMethodBinding, declaringClass ); >+ } >+ >+ public AnnotationInstance[] getAnnotations() >+ { >+ // make sure they are checked for problems/ >+ // this call will also initialize the 'compilerAnnotation' field. >+ getAnnotationTagBits(); >+ TypeDeclaration typeDecl = ((SourceTypeBinding)declaringClass).scope.referenceContext; >+ AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(this); >+ AnnotationInstance[] methodAnno = NoAnnotations; >+ if (methodDecl != null){ >+ final int len = methodDecl.annotations == null ? 0 : methodDecl.annotations.length; >+ if( len > 0 ){ >+ methodAnno = new AnnotationInstance[len]; >+ for( int i=0; i<len; i++ ){ >+ methodAnno[i] = methodDecl.annotations[i].compilerAnnotation; >+ } >+ } >+ } >+ return methodAnno; >+ } >+ >+ public AnnotationInstance[] getParameterAnnotations(final int index) >+ { >+ TypeDeclaration typeDecl = ((SourceTypeBinding)this.declaringClass).scope.referenceContext; >+ AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(this); >+ if(methodDecl != null ){ >+ final Argument[] args = methodDecl.arguments; >+ final int numArgs = args == null ? 0 : args.length; >+ if( numArgs == 0 || index < 0 || index >= numArgs ) >+ throw new IllegalArgumentException("number of parameters = " + numArgs + //$NON-NLS-1$ >+ " index = " + index ); //$NON-NLS-1$ >+ final Argument arg = args[index]; >+ final Annotation[] argAnnos = arg.annotations; >+ final int numAnnotations = argAnnos == null ? 0 : argAnnos.length; >+ AnnotationInstance[] result = NoAnnotations; >+ if( numAnnotations > 0 ){ >+ result = new SourceAnnotation[numAnnotations]; >+ // check for errors >+ ASTNode.resolveAnnotations(methodDecl.scope, argAnnos, this); >+ for( int j=0; j<numAnnotations; j++ ){ >+ result[j] = argAnnos[j].compilerAnnotation; >+ } >+ } >+ >+ return result; >+ } >+ >+ return NoAnnotations; >+ } >+ >+ public Object getDefaultValue() >+ { >+ TypeDeclaration typeDecl = ((SourceTypeBinding)this.declaringClass).scope.referenceContext; >+ final AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(this); >+ if( methodDecl instanceof AnnotationMethodDeclaration){ >+ return SourceElementValuePair.getValue(((AnnotationMethodDeclaration)methodDecl).defaultValue); >+ } >+ return null; >+ } >+} >Index: dom/org/eclipse/jdt/core/dom/AnnotationInstance.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/AnnotationInstance.java >diff -N dom/org/eclipse/jdt/core/dom/AnnotationInstance.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ dom/org/eclipse/jdt/core/dom/AnnotationInstance.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.dom; >+ >+public class AnnotationInstance implements IAnnotationInstance >+{ >+ static final AnnotationInstance[] NoAnnotations = new AnnotationInstance[0]; >+ private final org.eclipse.jdt.internal.compiler.lookup.AnnotationInstance internalAnnotation; >+ private final BindingResolver bindingResolver; >+ >+ AnnotationInstance(org.eclipse.jdt.internal.compiler.lookup.AnnotationInstance anno, >+ BindingResolver resolver ) >+ { >+ internalAnnotation = anno; >+ bindingResolver = resolver; >+ } >+ >+ public ITypeBinding getAnnotationType() { >+ final ITypeBinding binding = >+ this.bindingResolver.getTypeBinding(this.internalAnnotation.getAnnotationType()); >+ return binding.isAnnotation() ? binding : null; >+ } >+ >+ public IElementValuePair[] getDeclaredElementValuePairs() { >+ final org.eclipse.jdt.internal.compiler.lookup.ElementValuePair[] internalPair = >+ this.internalAnnotation.getElementValuePairs(); >+ final int len = internalPair.length; >+ IElementValuePair[] pairs = ElementValuePair.NoPair; >+ for( int i=0; i<len; i++ ){ >+ pairs[i] = new ElementValuePair(internalPair[i],this.bindingResolver); >+ } >+ return pairs; >+ } >+} >Index: dom/org/eclipse/jdt/core/dom/ElementValuePair.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/ElementValuePair.java >diff -N dom/org/eclipse/jdt/core/dom/ElementValuePair.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ dom/org/eclipse/jdt/core/dom/ElementValuePair.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.dom; >+ >+import org.eclipse.jdt.internal.compiler.impl.Constant; >+import org.eclipse.jdt.internal.compiler.lookup.TypeIds; >+ >+public class ElementValuePair implements IElementValuePair >+{ >+ static final ElementValuePair[] NoPair = new ElementValuePair[0]; >+ private static final Object NoValue = new Object(); >+ private final org.eclipse.jdt.internal.compiler.lookup.ElementValuePair internalPair; >+ private Object value = null; >+ private final BindingResolver bindingResolver; >+ >+ ElementValuePair(final org.eclipse.jdt.internal.compiler.lookup.ElementValuePair pair, >+ BindingResolver resolver) >+ { >+ this.internalPair = pair; >+ this.bindingResolver = resolver; >+ } >+ >+ private void init() >+ { >+ final org.eclipse.jdt.internal.compiler.lookup.TypeBinding type = this.internalPair.getType(); >+ this.value = buildDOMValue(this.internalPair.getValue(), type, this.bindingResolver); >+ if( this.value == null ) >+ this.value = NoValue; >+ } >+ >+ static Object buildDOMValue(final Object internalObject, >+ org.eclipse.jdt.internal.compiler.lookup.TypeBinding type, >+ BindingResolver resolver) >+ { >+ if( internalObject == null || type == null ) return null; >+ switch(type.id) >+ { >+ case TypeIds.T_boolean: >+ return new Boolean( ((Constant)internalObject).booleanValue() ); >+ case TypeIds.T_byte: >+ return new Byte( ((Constant)internalObject).byteValue() ); >+ case TypeIds.T_char: >+ return new Character( ((Constant)internalObject).charValue() ); >+ case TypeIds.T_double: >+ return new Double( ((Constant)internalObject).doubleValue() ); >+ case TypeIds.T_float: >+ return new Float( ((Constant)internalObject).floatValue() ); >+ case TypeIds.T_int: >+ return new Integer( ((Constant)internalObject).intValue() ); >+ case TypeIds.T_long: >+ return new Long( ((Constant)internalObject).longValue() ); >+ case TypeIds.T_short: >+ return new Short( ((Constant)internalObject).shortValue() ); >+ case TypeIds.T_JavaLangString: >+ return internalObject; >+ case TypeIds.T_JavaLangClass: >+ return resolver.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding)internalObject); >+ } >+ >+ if( type.isAnnotationType() ){ >+ return new AnnotationInstance( >+ (org.eclipse.jdt.internal.compiler.lookup.AnnotationInstance)internalObject, >+ resolver); >+ } >+ else if( type.isEnum() ){ >+ return resolver.getVariableBinding((org.eclipse.jdt.internal.compiler.lookup.FieldBinding)internalObject); >+ } >+ else if( type.isArrayType() ){ >+ final Object[] iElements = (Object[])internalObject; >+ final int len = iElements.length; >+ Object[] values = null; >+ if( len > 0){ >+ final org.eclipse.jdt.internal.compiler.lookup.TypeBinding elementType = >+ ((org.eclipse.jdt.internal.compiler.lookup.ArrayBinding)type).leafComponentType; >+ values = new Object[len]; >+ for( int i=0; i<len; i++ ){ >+ values[i] = buildDOMValue(iElements[i], elementType, resolver); >+ } >+ } >+ } >+ throw new IllegalStateException(); // should never get here. >+ } >+ >+ public String getName() { >+ final char[] membername = this.internalPair.getMemberName(); >+ return membername == null ? null : new String(membername); >+ } >+ >+ public IMethodBinding getMethodBinding() { >+ return this.bindingResolver.getMethodBinding(this.internalPair.getMethodBinding()); >+ } >+ >+ public ITypeBinding getElementType() { >+ final IMethodBinding methodBinding = getMethodBinding(); >+ if( methodBinding != null ) >+ return methodBinding.getReturnType(); >+ return null; >+ } >+ >+ public Object getElementValue() { >+ if( value == null ) >+ init(); >+ return value == NoValue ? null : this.value; >+ } >+} >Index: dom/org/eclipse/jdt/core/dom/IAnnotationInstance.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/IAnnotationInstance.java >diff -N dom/org/eclipse/jdt/core/dom/IAnnotationInstance.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ dom/org/eclipse/jdt/core/dom/IAnnotationInstance.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.dom; >+ >+/** >+ * Represents an instance of JSR 175 Annotation. >+ */ >+public interface IAnnotationInstance >+{ >+ /** >+ * Type of the annotation, which will always >+ * return <code>true</code> to <code>ITypeBinding.isAnnotation()</code> >+ * @return the type of the annotation. >+ */ >+ ITypeBinding getAnnotationType(); >+ >+ /** >+ * @return the array of declared element value pair of the annotation. >+ */ >+ IElementValuePair[] getDeclaredElementValuePairs(); >+} >Index: dom/org/eclipse/jdt/core/dom/IElementValuePair.java >=================================================================== >RCS file: dom/org/eclipse/jdt/core/dom/IElementValuePair.java >diff -N dom/org/eclipse/jdt/core/dom/IElementValuePair.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ dom/org/eclipse/jdt/core/dom/IElementValuePair.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * tyeung@bea.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.dom; >+ >+/** >+ * Represents an element value pair of an 175 Annotation instance. >+ */ >+public interface IElementValuePair >+{ >+ /** >+ * @return the name of the member >+ */ >+ public String getName(); >+ >+ /** >+ * @return the method binding that defines this element value pair. >+ */ >+ public IMethodBinding getMethodBinding(); >+ >+ /** >+ * This will determine the type of object returned in the {@link #getElementValue()} >+ * @return the type of the element value. >+ * >+ */ >+ public ITypeBinding getElementType(); >+ >+ /** >+ * If {@link #getElementType()} returns a primitive type, the result is the box >+ * equivalent. (i.e. <code>Integer</code> for type "int"). >+ * Return <code>String</code> if {@link #getElementType()} returns type <code>String</code> >+ * Return {@link ITypeBinding} if {@link #getElementType()} returns type <code>Class</code> >+ * Return {@link IVariableBinding} if {@link #getElementType()} returns an enum type. >+ * Return {@link IAnnotationInstance} if {@link #getElementType()} returns an annotation type. >+ * Return an <code>Object</code> array if {@link #getElementType()} returns an array type. >+ * >+ * @return the compile-time constant of this element or null if none exists. >+ * Return null if bindings are not requested when the DOM/AST is built. >+ */ >+ public Object getElementValue(); >+ >+} >Index: model/org/eclipse/jdt/core/compiler/CompilationParticipantEvent.java >=================================================================== >RCS file: model/org/eclipse/jdt/core/compiler/CompilationParticipantEvent.java >diff -N model/org/eclipse/jdt/core/compiler/CompilationParticipantEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/core/compiler/CompilationParticipantEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * mkaufman@bea.com - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.core.compiler; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.jdt.core.IJavaProject; >+ >+/** >+ * Generic base class for an event passed into ICompilationParticipant's notify() method. >+ * This is subclassed to provide event-specific return information. >+ * >+ * @see ICompilationParticipant#notify(CompilationParticipantEvent) >+ * @since 3.2 >+ */ >+public class CompilationParticipantEvent { >+ >+ /** >+ * Construct a new CompilationParticipantEvent for the specified IJavaProject >+ * @param jp The IJavaProject that this compilation event is occurring on >+ */ >+ public CompilationParticipantEvent( IJavaProject jp) >+ { >+ _javaProject = jp; >+ } >+ >+ /** >+ * @return an integer flag indicating the kind of event. One of the *_EVENT >+ * constants in ICompilationParticipant >+ * @see ICompilationParticipant#GENERIC_EVENT >+ */ >+ public int getKind() { return ICompilationParticipant.GENERIC_EVENT; } >+ >+ /** >+ * @return the IProject for this event >+ */ >+ public IProject getProject() { return _javaProject.getProject(); } >+ >+ /** >+ * @return the IJavaProject for this event >+ */ >+ public IJavaProject getJavaProject() { return _javaProject; } >+ >+ private IJavaProject _javaProject; >+} >Index: model/org/eclipse/jdt/core/compiler/CompilationParticipantResult.java >=================================================================== >RCS file: model/org/eclipse/jdt/core/compiler/CompilationParticipantResult.java >diff -N model/org/eclipse/jdt/core/compiler/CompilationParticipantResult.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/core/compiler/CompilationParticipantResult.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * mkaufman@bea.com - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.core.compiler; >+ >+/** >+ * A generic result object returned from ICompilationParticipant#notify. This is subclassed >+ * to provide event-specific return information. >+ * >+ * @see ICompilationParticipant#notify(CompilationParticipantEvent) >+ * @since 3.2 >+ */ >+public class CompilationParticipantResult { >+ >+ /** >+ * @return an integer flag indicating the kind of event this is a result for. >+ * One of the *_EVENT constants in ICompilationParticipant. >+ * @see ICompilationParticipant#GENERIC_EVENT >+ */ >+ public int getKind() { return ICompilationParticipant.GENERIC_EVENT; } >+ >+} >Index: model/org/eclipse/jdt/core/compiler/ICompilationParticipant.java >=================================================================== >RCS file: model/org/eclipse/jdt/core/compiler/ICompilationParticipant.java >diff -N model/org/eclipse/jdt/core/compiler/ICompilationParticipant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/core/compiler/ICompilationParticipant.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * mkaufman@bea.com - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.core.compiler; >+ >+/** >+ * Interface to extend when for a client that wants to participate in the compilation process >+ */ >+public interface ICompilationParticipant { >+ >+ public CompilationParticipantResult notify( CompilationParticipantEvent e ); >+ >+ >+ /** a flag indicating a generic event */ >+ public static final int GENERIC_EVENT = 1; >+ /** a flag indicating an event fired after reconcile */ >+ public static final int POST_RECONCILE_EVENT = 2; >+ /** a flag indicating an event fired before a build */ >+ public static final int PRE_BUILD_EVENT = 4; >+ /** a flag indicating an event fired after a build */ >+ public static final int POST_BUILD_EVENT = 8; >+} >Index: model/org/eclipse/jdt/core/compiler/PostBuildCompilationEvent.java >=================================================================== >RCS file: model/org/eclipse/jdt/core/compiler/PostBuildCompilationEvent.java >diff -N model/org/eclipse/jdt/core/compiler/PostBuildCompilationEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/core/compiler/PostBuildCompilationEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * mkaufman@bea.com - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.core.compiler; >+ >+import org.eclipse.jdt.core.IJavaProject; >+ >+/** >+ * An event class passed into ICompilationParticipant's notify() method after a build >+ * has completed. >+ * >+ * @see ICompilationParticipant#notify(CompilationParticipantEvent) >+ * @since 3.2 >+ */ >+public class PostBuildCompilationEvent extends CompilationParticipantEvent { >+ >+ PostBuildCompilationEvent( IJavaProject jp ) >+ { >+ super( jp ); >+ } >+ >+ /** >+ * @return an integer flag indicating that this is a post-build event. >+ * @see ICompilationParticipant#POST_BUILD_EVENT >+ * @see CompilationParticipantEvent#getKind() >+ */ >+ public final int getKind() { return ICompilationParticipant.POST_BUILD_EVENT; } >+} >Index: model/org/eclipse/jdt/core/compiler/PostBuildCompilationResult.java >=================================================================== >RCS file: model/org/eclipse/jdt/core/compiler/PostBuildCompilationResult.java >diff -N model/org/eclipse/jdt/core/compiler/PostBuildCompilationResult.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/core/compiler/PostBuildCompilationResult.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * mkaufman@bea.com - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.core.compiler; >+ >+/** >+ * An result class used as a return value from ICompilationParticipant's notify() method >+ * when responding to a post-build event. >+ * >+ * @see ICompilationParticipant#notify(CompilationParticipantEvent) >+ * @since 3.2 >+ */ >+public class PostBuildCompilationResult extends CompilationParticipantResult { >+ >+ /** >+ * @return an integer flag indicating that this is result for a post-build event. >+ * @see ICompilationParticipant#POST_BUILD_EVENT >+ * @see CompilationParticipantEvent#getKind() >+ */ >+ public final int getKind() { return ICompilationParticipant.POST_BUILD_EVENT; } >+} >Index: model/org/eclipse/jdt/core/compiler/PostReconcileCompilationEvent.java >=================================================================== >RCS file: model/org/eclipse/jdt/core/compiler/PostReconcileCompilationEvent.java >diff -N model/org/eclipse/jdt/core/compiler/PostReconcileCompilationEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/core/compiler/PostReconcileCompilationEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,58 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * mkaufman@bea.com - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.core.compiler; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+ >+/** >+ * An event class passed into ICompilationParticipant's notify() method after a reconcile >+ * has completed. >+ * >+ * @see ICompilationParticipant#notify(CompilationParticipantEvent) >+ * @since 3.2 >+ */ >+public class PostReconcileCompilationEvent extends CompilationParticipantEvent { >+ >+ /** >+ * constructs a new PostReconcileCompilationEvent >+ * >+ * @param cu - the ICompilationUnit that was just reconciled >+ * @param ast - the AST for for ICompilationUnit that was just reconciled >+ * @param jp - the java project for the ICompilationUnit that was reconciled >+ */ >+ public PostReconcileCompilationEvent( ICompilationUnit cu, CompilationUnit ast, IJavaProject jp ) >+ { >+ super( jp ); >+ _compilationUnit = cu; >+ _ast = ast; >+ } >+ >+ /** @return the AST for the ICompilationUnit that was just reconciled */ >+ public CompilationUnit getAst() { return _ast; } >+ >+ /** @return the ICompilationUnit that was just reconciled */ >+ public ICompilationUnit getCompilationUnit() { return _compilationUnit; } >+ >+ /** >+ * @return an integer flag indicating that this is a post-reconcile event. >+ * @see ICompilationParticipant#POST_RECONCILE_EVENT >+ * @see CompilationParticipantEvent#getKind() >+ */ >+ public final int getKind() { return ICompilationParticipant.POST_RECONCILE_EVENT; } >+ >+ private ICompilationUnit _compilationUnit; >+ private CompilationUnit _ast; >+ >+} >Index: model/org/eclipse/jdt/core/compiler/PostReconcileCompilationResult.java >=================================================================== >RCS file: model/org/eclipse/jdt/core/compiler/PostReconcileCompilationResult.java >diff -N model/org/eclipse/jdt/core/compiler/PostReconcileCompilationResult.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/core/compiler/PostReconcileCompilationResult.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * mkaufman@bea.com - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.core.compiler; >+ >+/** >+ * An result class used as a return value from ICompilationParticipant's notify() method >+ * when responding to a post-reconcile event. >+ * >+ * @see ICompilationParticipant#notify(CompilationParticipantEvent) >+ * @since 3.2 >+ */ >+public class PostReconcileCompilationResult extends CompilationParticipantResult { >+ >+ /** >+ * @return an integer flag indicating that this is result for a post-reconcile event. >+ * @see ICompilationParticipant#POST_RECONCILE_EVENT >+ * @see CompilationParticipantEvent#getKind() >+ */ >+ public final int getKind() { return ICompilationParticipant.POST_RECONCILE_EVENT; } >+ >+} >Index: model/org/eclipse/jdt/core/compiler/PreBuildCompilationEvent.java >=================================================================== >RCS file: model/org/eclipse/jdt/core/compiler/PreBuildCompilationEvent.java >diff -N model/org/eclipse/jdt/core/compiler/PreBuildCompilationEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/core/compiler/PreBuildCompilationEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,50 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * mkaufman@bea.com - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.core.compiler; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.jdt.core.IJavaProject; >+ >+/** >+ * An event class passed into ICompilationParticipant's notify() method before a build >+ * has completed. >+ * >+ * @see ICompilationParticipant#notify(CompilationParticipantEvent) >+ * @since 3.2 >+ */ >+public class PreBuildCompilationEvent extends CompilationParticipantEvent { >+ >+ /** >+ * @param files - IFile[] of the files about to be compiled >+ * @param jp - the IJavaProject for the IFiles[] being compiled >+ */ >+ public PreBuildCompilationEvent( IFile[] files, IJavaProject jp ) >+ { >+ super( jp ); >+ _files = files; >+ } >+ >+ /** >+ * @return - IFile[] containing the files about to be compiled >+ */ >+ public IFile[] getFiles() { return _files; } >+ >+ /** >+ * @return an integer flag indicating that this is a pre-build event. >+ * @see ICompilationParticipant#PRE_BUILD_EVENT >+ * @see CompilationParticipantEvent#getKind() >+ */ >+ public final int getKind() { return ICompilationParticipant.PRE_BUILD_EVENT; } >+ >+ private IFile[] _files; >+} >Index: model/org/eclipse/jdt/core/compiler/PreBuildCompilationResult.java >=================================================================== >RCS file: model/org/eclipse/jdt/core/compiler/PreBuildCompilationResult.java >diff -N model/org/eclipse/jdt/core/compiler/PreBuildCompilationResult.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/core/compiler/PreBuildCompilationResult.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,69 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 BEA Systems, Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * mkaufman@bea.com - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.core.compiler; >+ >+import java.util.Map; >+ >+import org.eclipse.core.resources.IFile; >+ >+/** >+ * An result class used as a return value from ICompilationParticipant's notify() method >+ * when responding to a pre-build event. >+ * >+ * @see ICompilationParticipant#notify(CompilationParticipantEvent) >+ * @since 3.2 >+ */ >+public class PreBuildCompilationResult extends CompilationParticipantResult { >+ >+ /** >+ * Construct a new PreBuildCompilationResult. >+ * >+ * @param files - array of newly generated files that need to be inserted into >+ * the compilation loop >+ * @param newDependencyInfo - Map<IFile, Set<String>> where each entry in the map >+ * is the set of fully-qualified type names which are new dependencies >+ * for the IFile. The JDT will record these new dependencies in its depdency >+ * matrix. >+ */ >+ public PreBuildCompilationResult( IFile[] files, Map newDependencyInfo ) >+ { >+ _files = files; >+ _newDependencyInfo = newDependencyInfo; >+ } >+ >+ /** >+ * >+ * @return IFile[] that is the set of new files to be added into the compilation >+ * set. >+ */ >+ public IFile[] getNewFiles() { return _files; } >+ >+ /** >+ * >+ * @return Map<IFile, Set<String>> that maps IFile to the fully-qualified type >+ * names of any new dependencies that need to be added into the JDT's dependency >+ * matrix. >+ */ >+ public Map getNewDependencies() { return _newDependencyInfo; } >+ >+ /** >+ * @return an integer flag indicating that this is result for a pre-build event. >+ * @see ICompilationParticipant#PRE_BUILD_EVENT >+ * @see CompilationParticipantEvent#getKind() >+ */ >+ public final int getKind() { return ICompilationParticipant.PRE_BUILD_EVENT; } >+ >+ private IFile[] _files; >+ private Map _newDependencyInfo; >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 90344
:
19892
|
19893
|
19925
|
19927