summaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authoravasseur <avasseur>2005-10-25 13:04:26 +0000
committeravasseur <avasseur>2005-10-25 13:04:26 +0000
commite1d674faa6a8f4d3f9ca051b88aab36d635eaf1b (patch)
tree09d1432ba5c2a3895c63c0870efd2cf401e844ba /org.aspectj.ajdt.core
parentcc6862f2b54c3333d645a0efb28f5366b0a2bcc3 (diff)
downloadaspectj-e1d674faa6a8f4d3f9ca051b88aab36d635eaf1b.tar.gz
aspectj-e1d674faa6a8f4d3f9ca051b88aab36d635eaf1b.zip
ajdtcore for abstract @Pointcut
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java36
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java42
2 files changed, 61 insertions, 17 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
index abe77d9f0..533919a92 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
@@ -88,12 +88,17 @@ public class PointcutDeclaration extends AjMethodDeclaration {
if (Modifier.isAbstract(this.declaredModifiers)) {
if (!(typeDec instanceof AspectDeclaration)) {
- typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd,
- "The abstract pointcut " + new String(declaredName) +
- " can only be defined in an aspect");
- ignoreFurtherInvestigation = true;
- return;
- } else if (!Modifier.isAbstract(typeDec.modifiers)) {
+ // check for @Aspect
+ if (isAtAspectJ(typeDec)) {
+ ;//no need to check abstract class as JDT does that
+ } else {
+ typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd,
+ "The abstract pointcut " + new String(declaredName) +
+ " can only be defined in an aspect");
+ ignoreFurtherInvestigation = true;
+ return;
+ }
+ } else if (!Modifier.isAbstract(typeDec.modifiers)) {
typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd,
"The abstract pointcut " + new String(declaredName) +
" can only be defined in an abstract aspect");
@@ -107,9 +112,22 @@ public class PointcutDeclaration extends AjMethodDeclaration {
pointcutDesignator.postParse(typeDec, this);
}
}
-
-
- /**
+
+ private boolean isAtAspectJ(TypeDeclaration typeDec) {
+ if (typeDec.annotations == null)
+ return false;
+
+ for (int i = 0; i < typeDec.annotations.length; i++) {
+ Annotation annotation = typeDec.annotations[i];
+ if ("Lorg/aspectj/lang/annotation/Aspect;".equals(new String(annotation.resolvedType.signature()))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
* Called from the AtAspectJVisitor to create the @Pointcut annotation
* (and corresponding method) for this pointcut
*
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java
index 7aae00ecd..3a7fe62e3 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java
@@ -490,8 +490,13 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor {
String pointcutExpression = getStringLiteralFor("value",ajAnnotations.pointcutAnnotation,pcLocation);
try {
ISourceContext context = new EclipseSourceContext(unit.compilationResult,pcLocation[0]);
- Pointcut pc = new PatternParser(pointcutExpression,context).parsePointcut();
- pcDecl.pointcutDesignator = new PointcutDesignator(pc);
+ Pointcut pc = null;//abstract
+ if (pointcutExpression == null || pointcutExpression.length() == 0) {
+ ;//will have to ensure abstract ()V method
+ } else {
+ pc = new PatternParser(pointcutExpression,context).parsePointcut();
+ }
+ pcDecl.pointcutDesignator = (pc==null)?null:new PointcutDesignator(pc);
pcDecl.setGenerateSyntheticPointcutMethod();
TypeDeclaration onType = (TypeDeclaration) typeStack.peek();
pcDecl.postParse(onType);
@@ -506,11 +511,14 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor {
// bindings[i] = new FormalBinding(type, name, i, arg.sourceStart, arg.sourceEnd, "unknown");
// }
swap(onType,methodDeclaration,pcDecl);
- pc.resolve(new EclipseScope(bindings,methodDeclaration.scope));
- HasIfPCDVisitor ifFinder = new HasIfPCDVisitor();
- pc.traverse(ifFinder, null);
- containsIfPcd = ifFinder.containsIfPcd;
- } catch(ParserException pEx) {
+ if (pc != null) {
+ // has an expression
+ pc.resolve(new EclipseScope(bindings,methodDeclaration.scope));
+ HasIfPCDVisitor ifFinder = new HasIfPCDVisitor();
+ pc.traverse(ifFinder, null);
+ containsIfPcd = ifFinder.containsIfPcd;
+ }
+ } catch(ParserException pEx) {
methodDeclaration.scope.problemReporter().parseError(
pcLocation[0] + pEx.getLocation().getStart(),
pcLocation[0] + pEx.getLocation().getEnd() ,
@@ -543,7 +551,25 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor {
methodDeclaration.returnType.sourceEnd,
"Pointcuts without an if() expression should have an empty method body");
}
- }
+
+ if (pcDecl.pointcutDesignator == null) {
+ if (Modifier.isAbstract(methodDeclaration.modifiers)
+ //those 2 checks makes sense for aop.xml concretization but NOT for regular abstraction of pointcut
+ //&& returnsVoid
+ //&& (methodDeclaration.arguments == null || methodDeclaration.arguments.length == 0)) {
+ ) {
+ ;//fine
+ } else {
+ methodDeclaration.scope.problemReporter().signalError(methodDeclaration.returnType.sourceStart,
+ methodDeclaration.returnType.sourceEnd,
+ "Method annotated with @Pointcut() for abstract pointcut must be abstract");
+ }
+ } else if (Modifier.isAbstract(methodDeclaration.modifiers)) {
+ methodDeclaration.scope.problemReporter().signalError(methodDeclaration.returnType.sourceStart,
+ methodDeclaration.returnType.sourceEnd,
+ "Method annotated with non abstract @Pointcut(\""+pointcutExpression+"\") is abstract");
+ }
+ }
private void copyAllFields(MethodDeclaration from, MethodDeclaration to) {
to.annotations = from.annotations;