diff options
author | aclement <aclement> | 2004-12-02 10:32:40 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-12-02 10:32:40 +0000 |
commit | 40820887f00b919b084e3ac2f5f7e3b03a9af50d (patch) | |
tree | 1d50c563d0f85e7b8a02769943bd411f09a71b56 /org.aspectj.ajdt.core/src | |
parent | 7296f648dfaf386a7cb577004f3e8f5dd5430ef3 (diff) | |
download | aspectj-40820887f00b919b084e3ac2f5f7e3b03a9af50d.tar.gz aspectj-40820887f00b919b084e3ac2f5f7e3b03a9af50d.zip |
72766 - when *source compiling* output messages to prevent ITD on enums/annotations
Diffstat (limited to 'org.aspectj.ajdt.core/src')
4 files changed, 45 insertions, 0 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java index 0d8e9c214..0ca059836 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java @@ -184,6 +184,8 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration { + + public EclipseTypeMunger build(ClassScope classScope) { EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope); @@ -192,6 +194,9 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration { binding = classScope.referenceContext.binding.resolveTypesFor(binding); + if (isTargetAnnotation(classScope,"constructor")) return null; // Error message output in isTargetAnnotation + if (isTargetEnum(classScope,"constructor")) return null; // Error message output in isTargetEnum + if (onTypeBinding.isInterface()) { classScope.problemReporter().signalError(sourceStart, sourceEnd, "can't define constructors on interfaces"); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java index c366e9f34..a10ab56de 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java @@ -40,6 +40,11 @@ public abstract class InterTypeDeclaration extends AjMethodDeclaration { protected ResolvedTypeMunger munger; protected int declaredModifiers; protected char[] declaredSelector; + + // XXXAJ5 - When the compiler is changed, these will exist somewhere in it... + private final static short ACC_ANNOTATION = 0x2000; + private final static short ACC_ENUM = 0x4000; + public InterTypeDeclaration(CompilationResult result, TypeReference onType) { super(result); @@ -56,6 +61,35 @@ public abstract class InterTypeDeclaration extends AjMethodDeclaration { this.selector = CharOperation.concat(selector, Integer.toHexString(sourceStart).toCharArray()); } + /** + * Checks that the target for the ITD is not an annotation. If it is, an error message + * is signaled. We return true if it is annotation so the caller knows to stop processing. + * kind is 'constructor', 'field', 'method' + */ + public boolean isTargetAnnotation(ClassScope classScope,String kind) { + if ((onTypeBinding.getAccessFlags() & ACC_ANNOTATION)!=0) { + classScope.problemReporter().signalError(sourceStart,sourceEnd, + "can't make inter-type "+kind+" declarations on annotation types."); + ignoreFurtherInvestigation = true; + return true; + } + return false; + } + + /** + * Checks that the target for the ITD is not an enum. If it is, an error message + * is signaled. We return true if it is enum so the caller knows to stop processing. + */ + public boolean isTargetEnum(ClassScope classScope,String kind) { + if ((onTypeBinding.getAccessFlags() & ACC_ENUM)!=0) { + classScope.problemReporter().signalError(sourceStart,sourceEnd, + "can't make inter-type "+kind+" declarations on enum types."); + ignoreFurtherInvestigation = true; + return true; + } + return false; + } + public void resolve(ClassScope upperScope) { if (ignoreFurtherInvestigation) return; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java index ac75f10ec..3df0df771 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java @@ -153,6 +153,9 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { binding = classScope.referenceContext.binding.resolveTypesFor(binding); if (ignoreFurtherInvestigation) return null; + if (isTargetAnnotation(classScope,"field")) return null; // Error message output in isTargetAnnotation + if (isTargetEnum(classScope,"field")) return null; // Error message output in isTargetEnum + if (!Modifier.isStatic(declaredModifiers)) { super.binding.parameters = new TypeBinding[] { onTypeBinding, diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java index 4cc9dae69..2f651430d 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java @@ -117,6 +117,9 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { //return null; throw new AbortCompilationUnit(compilationResult,null); } + if (isTargetAnnotation(classScope,"method")) return null; // Error message output in isTargetAnnotation + if (isTargetEnum(classScope,"method")) return null; // Error message output in isTargetEnum + ResolvedMember sig = new ResolvedMember(Member.METHOD, EclipseFactory.fromBinding(onTypeBinding), declaredModifiers, EclipseFactory.fromBinding(binding.returnType), new String(declaredSelector), EclipseFactory.fromBindings(binding.parameters), |