aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2005-03-10 20:35:22 +0000
committeraclement <aclement>2005-03-10 20:35:22 +0000
commit6ee78b248060211df114f28d0ad2b4d26ec726ff (patch)
treeb5a9e577eb2a16f2fc1cf915120b6d277a9ca8c2
parent3123880881836efb873481087cf9fcd81b1e4b15 (diff)
downloadaspectj-6ee78b248060211df114f28d0ad2b4d26ec726ff.tar.gz
aspectj-6ee78b248060211df114f28d0ad2b4d26ec726ff.zip
Declare annotation: filled in the blanks
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java48
1 files changed, 38 insertions, 10 deletions
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 7e4edec32..158228a4c 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
@@ -8,32 +8,60 @@
*
* Contributors:
* Adrian Colyer initial implementation
+ * Andy Clement wired up to back end
* ******************************************************************/
package org.aspectj.ajdt.internal.compiler.ast;
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.flow.FlowInfo;
+import org.aspectj.org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits;
import org.aspectj.weaver.patterns.DeclareAnnotation;
public class DeclareAnnotationDeclaration extends DeclareDeclaration {
+
private Annotation annotation;
-
+
public DeclareAnnotationDeclaration(CompilationResult result, DeclareAnnotation symbolicDeclare, Annotation annotation) {
- super(result,symbolicDeclare);
- this.annotation = annotation;
- addAnnotation(annotation);
- symbolicDeclare.setAnnotationString(annotation.toString());
- symbolicDeclare.setAnnotationMethod(new String(selector));
+ super(result,symbolicDeclare);
+ this.annotation = annotation;
+
+ addAnnotation(annotation);
+ if (symbolicDeclare==null) return; // there is an error that will already be getting reported (e.g. incorrect pattern on decaf/decac)
+ symbolicDeclare.setAnnotationString(annotation.toString());
+ symbolicDeclare.setAnnotationMethod(new String(selector));
}
+ public void analyseCode(ClassScope classScope,
+ InitializationFlowContext initializationContext, FlowInfo flowInfo) {
+ super.analyseCode(classScope, initializationContext, flowInfo);
+
+ long bits = annotation.resolvedType.getAnnotationTagBits();
+
+ if ((bits&TagBits.AnnotationTarget)!=0) {
+ // The annotation is stored against a method. For declare @type we need to
+ // confirm the annotation targets the right types. Earlier checking will
+ // have not found this problem because an annotation for target METHOD will
+ // not be reported on as we *do* store it against a method in this case
+ DeclareAnnotation.Kind k = ((DeclareAnnotation)declareDecl).getKind();
+ if (k.equals(DeclareAnnotation.AT_TYPE))
+ if ((bits&TagBits.AnnotationForMethod)!=0)
+ classScope.problemReporter().disallowedTargetForAnnotation(annotation);
+ if (k.equals(DeclareAnnotation.AT_FIELD))
+ if ((bits&TagBits.AnnotationForMethod)!=0)
+ classScope.problemReporter().disallowedTargetForAnnotation(annotation);
+ }
+
+ }
+
+
public Annotation getDeclaredAnnotation() {
return annotation;
}
- /* (non-Javadoc)
- * @see org.aspectj.ajdt.internal.compiler.ast.DeclareDeclaration#shouldDelegateCodeGeneration()
- */
protected boolean shouldDelegateCodeGeneration() {
return true; // declare annotation needs a method to be written out.
}
@@ -48,5 +76,5 @@ public class DeclareAnnotationDeclaration extends DeclareDeclaration {
}
this.annotations[0] = ann;
}
-
+
}