import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.aspectj.org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext;
public class DeclareAnnotationDeclaration extends DeclareDeclaration {
private Annotation annotation;
+ private boolean isRemover = false;
public DeclareAnnotationDeclaration(CompilationResult result, DeclareAnnotation symbolicDeclare, Annotation annotation) {
super(result, symbolicDeclare);
if (symbolicDeclare == null) {
return; // there is an error that will already be getting reported (e.g. incorrect pattern on decaf/decac)
}
+ this.isRemover = symbolicDeclare.isRemover();
symbolicDeclare.setAnnotationString(annotation.toString());
symbolicDeclare.setAnnotationLocation(annotation.sourceStart, annotation.sourceEnd);
}
public void analyseCode(ClassScope classScope, InitializationFlowContext initializationContext, FlowInfo flowInfo) {
super.analyseCode(classScope, initializationContext, flowInfo);
+ if (isRemover) {
+ if (((DeclareAnnotation) declareDecl).getKind() != DeclareAnnotation.AT_FIELD) {
+ 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)");
+ }
+ }
long bits = annotation.resolvedType.getAnnotationTagBits();
if ((bits & TagBits.AnnotationTarget) != 0) {
private void addAnnotation(Annotation ann) {
if (this.annotations == null) {
this.annotations = new Annotation[1];
- } else {
+ }
+ else {
Annotation[] old = this.annotations;
this.annotations = new Annotation[old.length + 1];
System.arraycopy(old, 0, this.annotations, 1, old.length);
}
}
+ public boolean isRemover() {
+ return isRemover;
+ }
}
public MethodDeclaration createDeclareAnnotationDeclaration(CompilationResult result, ASTNode pseudoTokens,
Annotation annotation, Parser parser, char kind) {
DeclareAnnotation declare = (DeclareAnnotation) ((PseudoTokens) pseudoTokens).parseAnnotationDeclare(parser);
- if (kind == '-') {
- declare.setRemover(true);
+ if (declare != null) {
+ if (kind == '-') {
+ declare.setRemover(true);
+ }
}
DeclareAnnotationDeclaration decl = new DeclareAnnotationDeclaration(result, declare, annotation);
return decl;
import java.util.Set;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.DeclareAnnotationDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.Proceed;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
super.parseErrorInsertAfterToken(start, end, currentKind, errorTokenSource, errorTokenName, expectedToken);
}
}
+
+ public void missingValueForAnnotationMember(Annotation annotation, char[] memberName) {
+ if (referenceContext instanceof DeclareAnnotationDeclaration) {
+ // If a remover then the values are not necessary
+ if (((DeclareAnnotationDeclaration)referenceContext).isRemover()) {
+ return;
+ }
+ }
+ super.missingValueForAnnotationMember(annotation, memberName);
+ }
}