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 58524 Details for
Bug 173376
[jsr269] Multiple annotations on class, only first is resolved
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Better patch
patch_173376.txt (text/plain), 8.10 KB, created by
Olivier Thomann
on 2007-02-07 23:34:26 EST
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-02-07 23:34:26 EST
Size:
8.10 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.compiler.apt >Index: batch/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.compiler.apt/batch/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java,v >retrieving revision 1.4 >diff -u -r1.4 AnnotationDiscoveryVisitor.java >--- batch/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java 16 Jan 2007 04:56:49 -0000 1.4 >+++ batch/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java 8 Feb 2007 04:31:59 -0000 >@@ -22,10 +22,7 @@ > import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; > import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; > import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; >-import org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation; > import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; >-import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation; >-import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation; > import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; > import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; > import org.eclipse.jdt.internal.compiler.lookup.Binding; >@@ -40,39 +37,50 @@ > */ > public class AnnotationDiscoveryVisitor extends ASTVisitor { > >- Binding currentBinding; >- boolean storeAnnotations; >- > /** > * Collects a many-to-many map of annotation types to > * the elements they appear on. > */ > ManyToMany<TypeElement, Element> _annoToElement; > >+ boolean storeAnnotations; >+ > public AnnotationDiscoveryVisitor() { > this._annoToElement = new ManyToMany<TypeElement, Element>(); > } > >+ @Override >+ public void endVisit(CompilationUnitDeclaration compilationUnitDeclaration, CompilationUnitScope scope) { >+ scope.compilerOptions().storeAnnotations = this.storeAnnotations; >+ } >+ >+ @Override > public boolean visit(Argument argument, BlockScope scope) { >- this.currentBinding = argument.binding; > Annotation[] annotations = argument.annotations; > if (annotations != null) { >- int annotationsLength = annotations.length; >- for (int i = 0; i < annotationsLength; i++) { >- annotations[i].traverse(this, scope); >- } >+ this.resolveAnnotations( >+ scope, >+ annotations, >+ argument.binding); > } > return false; > } > >+ @Override >+ public boolean visit(CompilationUnitDeclaration compilationUnitDeclaration, CompilationUnitScope scope) { >+ this.storeAnnotations = scope.compilerOptions().storeAnnotations; >+ scope.compilerOptions().storeAnnotations = true; >+ return true; >+ } >+ >+ @Override > public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) { >- this.currentBinding = constructorDeclaration.binding; > Annotation[] annotations = constructorDeclaration.annotations; > if (annotations != null) { >- int annotationsLength = annotations.length; >- for (int i = 0; i < annotationsLength; i++) { >- annotations[i].traverse(this, constructorDeclaration.scope); >- } >+ this.resolveAnnotations( >+ constructorDeclaration.scope, >+ annotations, >+ constructorDeclaration.binding); > } > Argument[] arguments = constructorDeclaration.arguments; > if (arguments != null) { >@@ -84,35 +92,25 @@ > return false; > } > >+ @Override > public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) { >- this.currentBinding = fieldDeclaration.binding; > Annotation[] annotations = fieldDeclaration.annotations; > if (annotations != null) { >- int annotationsLength = annotations.length; >- for (int i = 0; i < annotationsLength; i++) { >- annotations[i].traverse(this, scope); >- } >+ this.resolveAnnotations(scope, annotations, fieldDeclaration.binding); > } > return false; > } > >- public void endVisit(MarkerAnnotation annotation, BlockScope scope) { >- ASTNode.resolveAnnotations(scope, new Annotation[] { annotation }, this.currentBinding); >- AnnotationBinding binding = annotation.getCompilerAnnotation(); >- TypeElement anno = (TypeElement)ElementFactory.newElement(binding.getAnnotationType()); >- Element element = ElementFactory.newElement(this.currentBinding); >- _annoToElement.put(anno, element); >- } >- >+ @Override > public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) { >- this.currentBinding = methodDeclaration.binding; > Annotation[] annotations = methodDeclaration.annotations; > if (annotations != null) { >- int annotationsLength = annotations.length; >- for (int i = 0; i < annotationsLength; i++) { >- annotations[i].traverse(this, methodDeclaration.scope); >- } >+ this.resolveAnnotations( >+ methodDeclaration.scope, >+ annotations, >+ methodDeclaration.binding); > } >+ > Argument[] arguments = methodDeclaration.arguments; > if (arguments != null) { > int argumentLength = arguments.length; >@@ -123,54 +121,41 @@ > return false; > } > >- public void endVisit(NormalAnnotation annotation, BlockScope scope) { >- ASTNode.resolveAnnotations(scope, new Annotation[] { annotation }, this.currentBinding); >- AnnotationBinding binding = annotation.getCompilerAnnotation(); >- TypeElement anno = (TypeElement)ElementFactory.newElement(binding.getAnnotationType()); >- Element element = ElementFactory.newElement(this.currentBinding); >- _annoToElement.put(anno, element); >- } >- >- public void endVisit(SingleMemberAnnotation annotation, BlockScope scope) { >- ASTNode.resolveAnnotations(scope, new Annotation[] { annotation }, this.currentBinding); >- AnnotationBinding binding = annotation.getCompilerAnnotation(); >- TypeElement anno = (TypeElement)ElementFactory.newElement(binding.getAnnotationType()); >- Element element = ElementFactory.newElement(this.currentBinding); >- _annoToElement.put(anno, element); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration, >- * org.eclipse.jdt.internal.compiler.lookup.ClassScope) >- */ >+ @Override > public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) { >- this.currentBinding = memberTypeDeclaration.binding; >+ Annotation[] annotations = memberTypeDeclaration.annotations; >+ if (annotations != null) { >+ this.resolveAnnotations( >+ memberTypeDeclaration.staticInitializerScope, >+ annotations, >+ memberTypeDeclaration.binding); >+ } > return true; > } > >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration, >- * org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope) >- */ >+ @Override > public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) { >- this.currentBinding = typeDeclaration.binding; >+ Annotation[] annotations = typeDeclaration.annotations; >+ if (annotations != null) { >+ this.resolveAnnotations( >+ typeDeclaration.staticInitializerScope, >+ annotations, >+ typeDeclaration.binding); >+ } > return true; > } > >- @Override >- public void endVisit(CompilationUnitDeclaration compilationUnitDeclaration, CompilationUnitScope scope) { >- scope.compilerOptions().storeAnnotations = this.storeAnnotations; >- } >- >- @Override >- public boolean visit(CompilationUnitDeclaration compilationUnitDeclaration, CompilationUnitScope scope) { >- this.storeAnnotations = scope.compilerOptions().storeAnnotations; >- scope.compilerOptions().storeAnnotations = true; >- return true; >+ private void resolveAnnotations( >+ BlockScope scope, >+ Annotation[] annotations, >+ Binding currentBinding) { >+ ASTNode.resolveAnnotations(scope, annotations, currentBinding); >+ >+ for (Annotation annotation : annotations) { >+ AnnotationBinding binding = annotation.getCompilerAnnotation(); >+ TypeElement anno = (TypeElement)ElementFactory.newElement(binding.getAnnotationType()); >+ Element element = ElementFactory.newElement(currentBinding); >+ _annoToElement.put(anno, element); >+ } > } >- > }
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 173376
:
58509
|
58523
| 58524