diff options
author | acolyer <acolyer> | 2005-10-03 16:17:15 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-10-03 16:17:15 +0000 |
commit | 0fae66242efd3fd91dc7ace349cdcf7e5ebc2ade (patch) | |
tree | 85dda17da70b10b31b422853d1323421a82b3a21 /org.aspectj.ajdt.core | |
parent | c86fa6de889e521ebe8224d1a7579269c53ac357 (diff) | |
download | aspectj-0fae66242efd3fd91dc7ace349cdcf7e5ebc2ade.tar.gz aspectj-0fae66242efd3fd91dc7ace349cdcf7e5ebc2ade.zip |
completes all of the MAP bar ITDs
Diffstat (limited to 'org.aspectj.ajdt.core')
3 files changed, 98 insertions, 8 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java index 225ac7e0d..35ea7c5d3 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java @@ -297,7 +297,7 @@ public class AdviceDeclaration extends AjMethodDeclaration { } else if (kind == AdviceKind.Around) { adviceAnnotation = AtAspectJAnnotationFactory.createAroundAnnotation(pointcutExpression,declarationSourceStart); } - AtAspectJAnnotationFactory.addAnnotation(this, adviceAnnotation); + AtAspectJAnnotationFactory.addAnnotation(this, adviceAnnotation,this.scope); } // override, Called by ClassScope.postParse diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AtAspectJAnnotationFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AtAspectJAnnotationFactory.java index b8a8c8c37..79fdb87be 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AtAspectJAnnotationFactory.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AtAspectJAnnotationFactory.java @@ -20,6 +20,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits; /** @@ -44,6 +45,10 @@ public class AtAspectJAnnotationFactory { static final char[] around = "Around".toCharArray(); static final char[] pointcut = "Pointcut".toCharArray(); static final char[] declareErrorOrWarning = "ajcDeclareEoW".toCharArray(); + static final char[] declareParents = "ajcDeclareParents".toCharArray(); + static final char[] declareSoft = "ajcDeclareSoft".toCharArray(); + static final char[] declarePrecedence = "ajcDeclarePrecedence".toCharArray(); + static final char[] declareAnnotation = "ajcDeclareAnnotation".toCharArray(); /** * Create an @Aspect annotation for a code style aspect declaration starting at @@ -151,6 +156,66 @@ public class AtAspectJAnnotationFactory { return ann; } + public static Annotation createDeclareParentsAnnotation(String childPattern, String parentPatterns, boolean isExtends, int pos) { + char[][] typeName = new char[][] {org,aspectj,internal,lang,annotation,declareParents}; + long[] positions = new long[typeName.length]; + for (int i = 0; i < positions.length; i++) positions[i] = pos; + TypeReference annType = new QualifiedTypeReference(typeName,positions); + NormalAnnotation ann = new NormalAnnotation(annType,pos); + Expression targetExpression = new StringLiteral(childPattern.toCharArray(),pos,pos); + Expression parentsExpression = new StringLiteral(parentPatterns.toCharArray(),pos,pos); + Expression isExtendsExpression; + if (isExtends) { + isExtendsExpression = new TrueLiteral(pos,pos); + } else { + isExtendsExpression = new FalseLiteral(pos,pos); + } + MemberValuePair[] mvps = new MemberValuePair[3]; + mvps[0] = new MemberValuePair("targetTypePattern".toCharArray(),pos,pos,targetExpression); + mvps[1] = new MemberValuePair("parentTypes".toCharArray(),pos,pos,parentsExpression); + mvps[2] = new MemberValuePair("isExtends".toCharArray(),pos,pos,isExtendsExpression); + ann.memberValuePairs = mvps; + return ann; + } + + public static Annotation createDeclareSoftAnnotation(String pointcutExpression, String exceptionType, int pos) { + char[][] typeName = new char[][] {org,aspectj,internal,lang,annotation,declareSoft}; + long[] positions = new long[typeName.length]; + for (int i = 0; i < positions.length; i++) positions[i] = pos; + TypeReference annType = new QualifiedTypeReference(typeName,positions); + NormalAnnotation ann = new NormalAnnotation(annType,pos); + Expression pcutExpr = new StringLiteral(pointcutExpression.toCharArray(),pos,pos); + Expression exExpr = new StringLiteral(exceptionType.toCharArray(),pos,pos); + MemberValuePair[] mvps = new MemberValuePair[2]; + mvps[0] = new MemberValuePair("pointcut".toCharArray(),pos,pos,pcutExpr); + mvps[1] = new MemberValuePair("exceptionType".toCharArray(),pos,pos,exExpr); + ann.memberValuePairs = mvps; + return ann; + } + + public static Annotation createDeclareAnnAnnotation(String patternString, String annString, String kind, int pos) { + char[][] typeName = new char[][] {org,aspectj,internal,lang,annotation,declareAnnotation}; + long[] positions = new long[typeName.length]; + for (int i = 0; i < positions.length; i++) positions[i] = pos; + TypeReference annType = new QualifiedTypeReference(typeName,positions); + NormalAnnotation ann = new NormalAnnotation(annType,pos); + Expression pattExpr = new StringLiteral(patternString.toCharArray(),pos,pos); + Expression annExpr = new StringLiteral(annString.toCharArray(),pos,pos); + Expression kindExpr = new StringLiteral(kind.toCharArray(),pos,pos); + MemberValuePair[] mvps = new MemberValuePair[3]; + mvps[0] = new MemberValuePair("pattern".toCharArray(),pos,pos,pattExpr); + mvps[1] = new MemberValuePair("annotation".toCharArray(),pos,pos,annExpr); + mvps[2] = new MemberValuePair("kind".toCharArray(),pos,pos,kindExpr); + ann.memberValuePairs = mvps; + return ann; + } + + public static Annotation createDeclarePrecedenceAnnotation(String pointcutExpression, int pos) { + char[][] typeName = new char[][] {org,aspectj,internal,lang,annotation,declarePrecedence}; + return makeSingleStringMemberAnnotation(typeName, pos, pointcutExpression); + + } + private static Annotation makeSingleStringMemberAnnotation(char[][] name, int pos, String annValue) { long[] positions = new long[name.length]; for (int i = 0; i < positions.length; i++) positions[i] = pos; @@ -163,7 +228,7 @@ public class AtAspectJAnnotationFactory { return ann; } - public static void addAnnotation(AjMethodDeclaration decl, Annotation annotation) { + public static void addAnnotation(AjMethodDeclaration decl, Annotation annotation, BlockScope scope) { if (decl.annotations == null) { decl.annotations = new Annotation[] { annotation }; } else { @@ -173,7 +238,9 @@ public class AtAspectJAnnotationFactory { decl.annotations[old.length] = annotation; } if (decl.binding!= null) { - decl.binding.tagBits -= TagBits.AnnotationResolved; + if ((decl.binding.tagBits & TagBits.AnnotationResolved) != 0) { + annotation.resolve(scope); + } } } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java index e9988b6e0..d0d62dffb 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java @@ -15,6 +15,9 @@ package org.aspectj.ajdt.internal.compiler.ast; //import java.util.List; +import java.util.Collection; +import java.util.Iterator; + import org.aspectj.ajdt.internal.compiler.lookup.EclipseScope; import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; @@ -25,6 +28,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser; import org.aspectj.weaver.AjAttribute; +import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.patterns.Declare; import org.aspectj.weaver.patterns.DeclareAnnotation; import org.aspectj.weaver.patterns.DeclareErrorOrWarning; @@ -58,19 +62,38 @@ public class DeclareDeclaration extends AjMethodDeclaration { public void addAtAspectJAnnotations() { Annotation annotation = null; if (declareDecl instanceof DeclareAnnotation) { - + DeclareAnnotation da = (DeclareAnnotation) declareDecl; + String patternString = da.getPatternAsString(); + String annString = da.getAnnotationString(); + String kind = da.getKind().toString(); + annotation = AtAspectJAnnotationFactory.createDeclareAnnAnnotation( + patternString,annString,kind,declarationSourceStart); } else if (declareDecl instanceof DeclareErrorOrWarning) { DeclareErrorOrWarning dd = (DeclareErrorOrWarning) declareDecl; annotation = AtAspectJAnnotationFactory .createDeclareErrorOrWarningAnnotation(dd.getPointcut().toString(),dd.getMessage(),dd.isError(),declarationSourceStart); } else if (declareDecl instanceof DeclareParents) { - + DeclareParents dp = (DeclareParents) declareDecl; + String childPattern = dp.getChild().toString(); + Collection parentPatterns = dp.getParents().getExactTypes(); + StringBuffer parents = new StringBuffer(); + for (Iterator iter = parentPatterns.iterator(); iter.hasNext();) { + UnresolvedType urt = ((UnresolvedType) iter.next()); + parents.append(urt.getName()); + if (iter.hasNext()) parents.append(", "); + } + annotation = AtAspectJAnnotationFactory + .createDeclareParentsAnnotation(childPattern,parents.toString(),dp.isExtends(),declarationSourceStart); } else if (declareDecl instanceof DeclarePrecedence) { - + DeclarePrecedence dp = (DeclarePrecedence) declareDecl; + String precedenceList = dp.getPatterns().toString(); + annotation = AtAspectJAnnotationFactory.createDeclarePrecedenceAnnotation(precedenceList,declarationSourceStart); } else if (declareDecl instanceof DeclareSoft) { - + DeclareSoft ds = (DeclareSoft) declareDecl; + annotation = AtAspectJAnnotationFactory + .createDeclareSoftAnnotation(ds.getPointcut().toString(),ds.getException().getExactType().getName(),declarationSourceStart); } - if (annotation != null) AtAspectJAnnotationFactory.addAnnotation(this,annotation); + if (annotation != null) AtAspectJAnnotationFactory.addAnnotation(this,annotation,this.scope); } /** |