diff options
author | aclement <aclement> | 2005-11-17 12:45:18 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-11-17 12:45:18 +0000 |
commit | 555eae61fec76c78376a76803cd3b67171e1ddb6 (patch) | |
tree | 55aba1a257db7210bfe70186214f911eb10d5156 /org.aspectj.ajdt.core | |
parent | 608688ca74d3c19da3124a917c390232bca610a2 (diff) | |
download | aspectj-555eae61fec76c78376a76803cd3b67171e1ddb6.tar.gz aspectj-555eae61fec76c78376a76803cd3b67171e1ddb6.zip |
fixes for pr115237
Diffstat (limited to 'org.aspectj.ajdt.core')
2 files changed, 52 insertions, 21 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java index 78387f762..1f9868a6e 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java @@ -45,6 +45,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InvocationSite; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; @@ -974,6 +975,18 @@ public class AspectDeclaration extends TypeDeclaration { } else { return null; } + } else if (binding instanceof ParameterizedTypeBinding) { + ParameterizedTypeBinding pBinding = (ParameterizedTypeBinding)binding; + if (pBinding.type instanceof SourceTypeBinding) { + SourceTypeBinding sourceSc = (SourceTypeBinding)pBinding.type; + if (sourceSc.scope.referenceContext instanceof AspectDeclaration) { + perClause = ((AspectDeclaration)sourceSc.scope.referenceContext).perClause; + } else { + return null; + } + } else { + perClause=null; + } } else { //XXX need to handle this too return null; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java index bb45da937..9e6a24fae 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java @@ -32,6 +32,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.NormalAnnotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; @@ -393,9 +394,16 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { return new PerSingleton(); } else { // for @Aspect, we do need the real kind though we don't need the real perClause - PerClause.Kind kind = getPerClauseForTypeDeclaration(declaration); - //returning a perFromSuper is enough to get the correct kind.. (that's really a hack - AV) - return new PerFromSuper(kind); + // at least try to get the right perclause + PerClause pc = null; + if (declaration instanceof AspectDeclaration) + pc = ((AspectDeclaration)declaration).perClause; + if (pc==null) { + PerClause.Kind kind = getPerClauseForTypeDeclaration(declaration); + //returning a perFromSuper is enough to get the correct kind.. (that's really a hack - AV) + return new PerFromSuper(kind); + } + return pc; } } @@ -419,24 +427,13 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { // it is an @Aspect(...something...) SingleMemberAnnotation theAnnotation = (SingleMemberAnnotation)annotation; String clause = new String(((StringLiteral)theAnnotation.memberValue).source());//TODO cast safe ? - if (clause.startsWith("perthis(")) { - return PerClause.PEROBJECT; - } else if (clause.startsWith("pertarget(")) { - return PerClause.PEROBJECT; - } else if (clause.startsWith("percflow(")) { - return PerClause.PERCFLOW; - } else if (clause.startsWith("percflowbelow(")) { - return PerClause.PERCFLOW; - } else if (clause.startsWith("pertypewithin(")) { - return PerClause.PERTYPEWITHIN; - } else if (clause.startsWith("issingleton(")) { - return PerClause.SINGLETON; - } else { - eclipseWorld().showMessage(IMessage.ABORT, - "cannot determine perClause '" + clause + "'", - new EclipseSourceLocation(typeDeclaration.compilationResult, typeDeclaration.sourceStart, typeDeclaration.sourceEnd), null); - return PerClause.SINGLETON;//fallback strategy just to avoid NPE - } + return determinePerClause(typeDeclaration, clause); + } else if (annotation instanceof NormalAnnotation) { // this kind if it was added by the visitor ! + // it is an @Aspect(...something...) + NormalAnnotation theAnnotation = (NormalAnnotation)annotation; + if (theAnnotation.memberValuePairs==null || theAnnotation.memberValuePairs.length<1) return PerClause.SINGLETON; + String clause = new String(((StringLiteral)theAnnotation.memberValuePairs[0].value).source());//TODO cast safe ? + return determinePerClause(typeDeclaration, clause); } else { eclipseWorld().showMessage(IMessage.ABORT, "@Aspect annotation is expected to be SingleMemberAnnotation with 'String value()' as unique element", @@ -448,6 +445,27 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { return null;//no @Aspect annotation at all (not as aspect) } + private PerClause.Kind determinePerClause(TypeDeclaration typeDeclaration, String clause) { + if (clause.startsWith("perthis(")) { + return PerClause.PEROBJECT; + } else if (clause.startsWith("pertarget(")) { + return PerClause.PEROBJECT; + } else if (clause.startsWith("percflow(")) { + return PerClause.PERCFLOW; + } else if (clause.startsWith("percflowbelow(")) { + return PerClause.PERCFLOW; + } else if (clause.startsWith("pertypewithin(")) { + return PerClause.PERTYPEWITHIN; + } else if (clause.startsWith("issingleton(")) { + return PerClause.SINGLETON; + } else { + eclipseWorld().showMessage(IMessage.ABORT, + "cannot determine perClause '" + clause + "'", + new EclipseSourceLocation(typeDeclaration.compilationResult, typeDeclaration.sourceStart, typeDeclaration.sourceEnd), null); + return PerClause.SINGLETON;//fallback strategy just to avoid NPE + } + } + // adapted from AspectDeclaration private PerClause.Kind lookupPerClauseKind(ReferenceBinding binding) { final PerClause.Kind kind; |