From: Andy Clement Date: Thu, 16 Aug 2012 20:18:30 +0000 (-0700) Subject: Some preliminary work on this bug X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fheads%2Fbug356694;p=aspectj.git Some preliminary work on this bug This includes a change in shadows in Parser class: protected void consumeDeclareAnnotation(char kind) { concatNodeLists(); ASTNode tokens = popPseudoTokens(";"); int annotationCount = this.expressionLengthPtr+1; Annotation[] annotations = new Annotation[annotationCount]; int count = 0; int length; while (this.expressionLengthPtr>0 && (length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { System.arraycopy( this.expressionStack, (this.expressionPtr -= length) + 1, annotations = new Annotation[length], count++, length); } // int length; // Annotation[] annotations = new Annotation[1]; // there should only ever be one for us... // if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { // System.arraycopy( // this.expressionStack, // (this.expressionPtr -= length) + 1, // annotations = new Annotation[length], // 0, // length); // } MethodDeclaration declareDecl = declarationFactory.createDeclareAnnotationDeclaration(this.compilationUnit.compilationResult,tokens,annotations,this,kind); pushOnAstStack(declareDecl); } It touches so much code though and requires a change to serialized form. --- diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java index 7f1880590..5f2fceee6 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java @@ -25,22 +25,31 @@ import org.aspectj.weaver.patterns.DeclareAnnotation; public class DeclareAnnotationDeclaration extends DeclareDeclaration { - private Annotation annotation; +// private Annotation[] annotation; private boolean isRemover = false; - public DeclareAnnotationDeclaration(CompilationResult result, DeclareAnnotation symbolicDeclare, Annotation annotation) { + public DeclareAnnotationDeclaration(CompilationResult result, DeclareAnnotation symbolicDeclare, Annotation[] annotations) { super(result, symbolicDeclare); - this.annotation = annotation; +// this.annotations = annotations; - addAnnotation(annotation); + for (int a=0;a0) { + sb.append(" "); + } + sb.append(annotations[a].toString()); + } + symbolicDeclare.setAnnotationString(sb.toString()); + symbolicDeclare.setAnnotationLocation(annotations[0].sourceStart, annotations[annotations.length-1].sourceEnd); } - + public void analyseCode(ClassScope classScope, InitializationFlowContext initializationContext, FlowInfo flowInfo) { super.analyseCode(classScope, initializationContext, flowInfo); @@ -49,35 +58,41 @@ public class DeclareAnnotationDeclaration extends DeclareDeclaration { classScope.problemReporter().signalError(this.sourceStart(), this.sourceEnd, "Annotation removal only supported for declare @field (compiler limitation)"); } - else if (isRemover && !(annotation instanceof MarkerAnnotation)) { - classScope.problemReporter().signalError(this.sourceStart(), this.sourceEnd, - "Annotation removal does not allow values to be specified for the annotation (compiler limitation)"); + else if (isRemover) { // && !(annotation instanceof MarkerAnnotation)) { + for (int a=0;a annotationMethods; private List annotationStrings; - private AnnotationAJ annotation; // discovered when required - private ResolvedType annotationType; // discovered when required + private AnnotationAJ[] annotations; // discovered when required + private ResolvedType[] annotationTypes; // discovered when required // not serialized: private int annotationStart; @@ -150,7 +150,7 @@ public class DeclareAnnotation extends Declare { } ret.annotationMethods = this.annotationMethods; ret.annotationStrings = this.annotationStrings; - ret.annotation = this.annotation; + ret.annotations = this.annotations; ret.containingAspect = this.containingAspect; ret.copyLocationFrom(this); return ret; @@ -365,7 +365,7 @@ public class DeclareAnnotation extends Declare { * finds that method and retrieves the annotation */ private void ensureAnnotationDiscovered() { - if (annotation != null) { + if (annotations != null) { return; } String annotationMethod = annotationMethods.get(0); @@ -427,9 +427,10 @@ public class DeclareAnnotation extends Declare { /** * @return the type of the annotation */ - public ResolvedType getAnnotationType() { - if (annotationType == null) { + public ResolvedType[] getAnnotationTypes() { + if (annotationTypes == null) { String annotationMethod = annotationMethods.get(0); + List annoTypesToStore = new ArrayList(); for (Iterator iter = containingAspect.getMethods(true, true); iter.hasNext();) { ResolvedMember member = iter.next(); if (member.getName().equals(annotationMethod)) { @@ -439,23 +440,20 @@ public class DeclareAnnotation extends Declare { return null; } int idx = 0; - if (annoTypes[0].getSignature().equals("Lorg/aspectj/internal/lang/annotation/ajcDeclareAnnotation;")) { - idx = 1; + for (int i=0;i