Browse Source

72766 - when *source compiling* output messages to prevent ITD on enums/annotations

tags/Root_AspectJ5_Development
aclement 19 years ago
parent
commit
40820887f0

+ 5
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java View File

@@ -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");

+ 34
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java View File

@@ -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;

+ 3
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java View File

@@ -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,

+ 3
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java View File

@@ -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),

Loading…
Cancel
Save