aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java27
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java3
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java3
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/AndPointcut.java3
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java8
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java10
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/IdentityPointcutVisitor.java234
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/IfPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java3
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ModifiersPattern.java3
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/NamePattern.java3
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/NotPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/OrPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PatternNode.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PatternParser.java3
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java215
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/Pointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PointcutVisitor.java623
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java5
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java8
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/TypePattern.java16
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/TypePatternList.java3
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java4
43 files changed, 1277 insertions, 23 deletions
diff --git a/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java b/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java
index 512f9ca4f..99ce3bd50 100644
--- a/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java
@@ -25,6 +25,12 @@ import java.util.HashMap;
import org.aspectj.weaver.patterns.Pointcut;
import org.aspectj.weaver.patterns.FastMatchInfo;
import org.aspectj.weaver.patterns.PerClause;
+import org.aspectj.weaver.patterns.PointcutVisitor;
+import org.aspectj.weaver.patterns.PatternNode;
+import org.aspectj.weaver.patterns.PerThisOrTargetPointcutVisitor;
+import org.aspectj.weaver.patterns.PerObject;
+import org.aspectj.weaver.patterns.TypePattern;
+import org.aspectj.weaver.patterns.PerFromSuper;
import org.aspectj.util.FuzzyBoolean;
public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger {
@@ -86,9 +92,28 @@ public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger {
}
public boolean matches(ResolvedTypeX matchType, ResolvedTypeX aspectType) {
+ if (matchType.isInterface()) return false;
+
+ //FIXME AV - cache that
+ final boolean isPerThis;
+ if (aspectType.getPerClause() instanceof PerFromSuper) {
+ PerFromSuper ps = (PerFromSuper) aspectType.getPerClause();
+ isPerThis = ((PerObject)ps.lookupConcretePerClause(aspectType)).isThis();
+ } else {
+ isPerThis = ((PerObject)aspectType.getPerClause()).isThis();
+ }
+ PerThisOrTargetPointcutVisitor v = new PerThisOrTargetPointcutVisitor(
+ !isPerThis,
+ aspectType
+ );
+ TypePattern tp = v.getPerTypePointcut(testPointcut);
+
+ if (true) return tp.matchesStatically(matchType);
+
+
//FIXME ATAJ waiting Andy patch...
// comment from Andy - this is hard to fix...
-
+
// right now I filter @AJ aspect else it end up with duplicate members
//return !matchType.isInterface() && !matchType.isAnnotationStyleAspect();
Set aspects = (Set)s_advisedTypeToAspects.get(matchType);
diff --git a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
index 164047189..5de34cf38 100644
--- a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
+++ b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
@@ -52,6 +52,7 @@ import org.aspectj.weaver.patterns.Pointcut;
import org.aspectj.weaver.patterns.SimpleScope;
import org.aspectj.weaver.patterns.TypePattern;
import org.aspectj.weaver.patterns.PerFromSuper;
+import org.aspectj.weaver.patterns.PointcutVisitor;
import java.util.ArrayList;
import java.util.Collections;
@@ -1331,7 +1332,7 @@ public class AtAjAttributes {
pointcut.setLocation(location.context, -1, -1);//FIXME -1,-1 is not good enough
return pointcut;
} catch (ParserException e) {
- reportError("Invalid pointcut '" + pointcutString + "' : " + e.getLocation(), location);
+ reportError("Invalid pointcut '" + pointcutString + "': " + e.toString(), location);
return null;
}
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java
index 018a0e8fc..077840632 100644
--- a/weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java
@@ -89,4 +89,7 @@ public class AndAnnotationTypePattern extends AnnotationTypePattern {
public AnnotationTypePattern getLeft() { return left; }
public AnnotationTypePattern getRight() { return right; }
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java b/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java
index 4bb8b1ce4..a688e66b9 100644
--- a/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java
@@ -146,4 +146,7 @@ public class AndPointcut extends Pointcut {
return right;
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java
index 022ba5570..b56817b7f 100644
--- a/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java
@@ -30,7 +30,7 @@ import org.aspectj.weaver.VersionedDataInputStream;
* @author Jim Hugunin
*/
public class AndTypePattern extends TypePattern {
- private TypePattern left, right;
+ TypePattern left, right;
public AndTypePattern(TypePattern left, TypePattern right) {
super(false,false); //?? we override all methods that care about includeSubtypes
@@ -160,5 +160,9 @@ public class AndTypePattern extends TypePattern {
ret = ret + 37 * right.hashCode();
return ret;
}
-
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java b/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java
index df3833009..75dbb73a8 100644
--- a/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java
+++ b/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java
@@ -176,5 +176,9 @@ public class AnnotationPatternList extends PatternNode {
}
writeLocation(s);
}
-
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java
index b7c8ed7b4..ae611aea2 100644
--- a/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java
@@ -60,7 +60,7 @@ import org.aspectj.weaver.bcel.BcelTypeMunger;
*/
public class AnnotationPointcut extends NameBindingPointcut {
- private ExactAnnotationTypePattern annotationTypePattern;
+ ExactAnnotationTypePattern annotationTypePattern;
private ShadowMunger munger = null; // only set after concretization
public AnnotationPointcut(ExactAnnotationTypePattern type) {
@@ -262,4 +262,8 @@ public class AnnotationPointcut extends NameBindingPointcut {
return buf.toString();
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java
index df25c75fb..831c6f8c4 100644
--- a/weaver/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java
@@ -99,6 +99,11 @@ class AnyAnnotationTypePattern extends AnnotationTypePattern {
}
public String toString() { return "@ANY"; }
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
}
class EllipsisAnnotationTypePattern extends AnnotationTypePattern {
@@ -115,4 +120,9 @@ class EllipsisAnnotationTypePattern extends AnnotationTypePattern {
}
public String toString() { return ".."; }
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
} \ No newline at end of file
diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
index ce9125476..dc9d43993 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
@@ -39,7 +39,7 @@ import org.aspectj.weaver.ast.Var;
*/
public class ArgsAnnotationPointcut extends NameBindingPointcut {
- private AnnotationPatternList arguments;
+ AnnotationPatternList arguments;
/**
*
@@ -216,4 +216,8 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut {
buf.append(arguments.toString());
return buf.toString();
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
index 15198d92d..1a30fdd72 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
@@ -303,4 +303,8 @@ public class ArgsPointcut extends NameBindingPointcut {
public String toString() {
return "args" + arguments.toString() + "";
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java b/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java
index f6133bc71..3b0611adc 100644
--- a/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java
@@ -44,7 +44,7 @@ import org.aspectj.weaver.ast.Test;
public class CflowPointcut extends Pointcut {
private Pointcut entry; // The pointcut inside the cflow() that represents the 'entry' point
- private boolean isBelow;// Is this cflowbelow?
+ boolean isBelow;// Is this cflowbelow?
private int[] freeVars;
private static Hashtable cflowFields = new Hashtable();
@@ -308,4 +308,8 @@ public class CflowPointcut extends Pointcut {
}
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java
index 9c1309c74..360b6456f 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java
@@ -140,6 +140,10 @@ public class ConcreteCflowPointcut extends Pointcut {
throw new RuntimeException("unimplemented");
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
public static class Slot {
int formalIndex;
diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
index 8e1b17d17..f098d36f6 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
@@ -221,4 +221,8 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
if (formalName != null) ret = ret + " " + formalName;
return ret;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
index 6776579f3..d9e814003 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
@@ -262,4 +262,8 @@ public class ExactTypePattern extends TypePattern {
throw new IllegalStateException("trying to re-resolve");
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java b/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java
index 0c3b80385..8cc32353c 100644
--- a/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java
@@ -156,4 +156,8 @@ public class HandlerPointcut extends Pointcut {
ret.copyLocationFrom(this);
return ret;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/IdentityPointcutVisitor.java b/weaver/src/org/aspectj/weaver/patterns/IdentityPointcutVisitor.java
new file mode 100644
index 000000000..a05fe013f
--- /dev/null
+++ b/weaver/src/org/aspectj/weaver/patterns/IdentityPointcutVisitor.java
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Vasseur initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver.patterns;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class IdentityPointcutVisitor implements PointcutVisitor {
+
+ public Object visit(AnyTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(NoTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(EllipsisTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(AnyWithAnnotationTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(AnyAnnotationTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(EllipsisAnnotationTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(AndAnnotationTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(AndPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(AndTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(AnnotationPatternList node, Object data) {
+ return node;
+ }
+
+ public Object visit(AnnotationPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(ArgsAnnotationPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(ArgsPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(BindingAnnotationTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(BindingTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(CflowPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(ConcreteCflowPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(DeclareAnnotation node, Object data) {
+ return node;
+ }
+
+ public Object visit(DeclareErrorOrWarning node, Object data) {
+ return node;
+ }
+
+ public Object visit(DeclareParents node, Object data) {
+ return node;
+ }
+
+ public Object visit(DeclarePrecedence node, Object data) {
+ return node;
+ }
+
+ public Object visit(DeclareSoft node, Object data) {
+ return node;
+ }
+
+ public Object visit(ExactAnnotationTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(ExactTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(HandlerPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(IfPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(KindedPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(ModifiersPattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(NamePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(NotAnnotationTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(NotPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(NotTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(OrAnnotationTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(OrPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(OrTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(PerCflow node, Object data) {
+ return node;
+ }
+
+ public Object visit(PerFromSuper node, Object data) {
+ return node;
+ }
+
+ public Object visit(PerObject node, Object data) {
+ return node;
+ }
+
+ public Object visit(PerSingleton node, Object data) {
+ return node;
+ }
+
+ public Object visit(PerTypeWithin node, Object data) {
+ return node;
+ }
+
+ public Object visit(PatternNode node, Object data) {
+ throw new ParserException("Should implement for " + node.getClass(), null);
+ }
+
+ public Object visit(ReferencePointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(SignaturePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(ThisOrTargetAnnotationPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(ThisOrTargetPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(ThrowsPattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(TypePatternList node, Object data) {
+ return node;
+ }
+
+ public Object visit(WildAnnotationTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(WildTypePattern node, Object data) {
+ return node;
+ }
+
+ public Object visit(WithinAnnotationPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(WithinCodeAnnotationPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(WithinPointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(WithincodePointcut node, Object data) {
+ return node;
+ }
+
+ public Object visit(Pointcut.MatchesNothingPointcut node, Object data) {
+ return node;
+ }
+}
diff --git a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
index 39d2fdb8c..9a716e6e6 100644
--- a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
@@ -277,6 +277,10 @@ public class IfPointcut extends Pointcut {
return ret;
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
private static class IfFalsePointcut extends IfPointcut {
public IfFalsePointcut() {
diff --git a/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java b/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
index 26749020b..61123362a 100644
--- a/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
@@ -311,4 +311,7 @@ public class KindedPointcut extends Pointcut {
return kind;
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ModifiersPattern.java b/weaver/src/org/aspectj/weaver/patterns/ModifiersPattern.java
index ad11cfd12..a3f5eedce 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ModifiersPattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ModifiersPattern.java
@@ -93,4 +93,7 @@ public class ModifiersPattern extends PatternNode {
return flag.intValue();
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/NamePattern.java b/weaver/src/org/aspectj/weaver/patterns/NamePattern.java
index 9ede44bf2..a2879b1ea 100644
--- a/weaver/src/org/aspectj/weaver/patterns/NamePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/NamePattern.java
@@ -158,4 +158,7 @@ public class NamePattern extends PatternNode {
return starCount == 1 && pattern.length == 1;
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java
index 694cf4652..37acaa16b 100644
--- a/weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java
@@ -20,7 +20,7 @@ import org.aspectj.weaver.World;
public class NotAnnotationTypePattern extends AnnotationTypePattern {
- private AnnotationTypePattern negatedPattern;
+ AnnotationTypePattern negatedPattern;
public NotAnnotationTypePattern(AnnotationTypePattern pattern) {
this.negatedPattern = pattern;
@@ -83,4 +83,8 @@ public class NotAnnotationTypePattern extends AnnotationTypePattern {
public AnnotationTypePattern getNegatedPattern() {
return negatedPattern;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java b/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java
index bdbecfcbf..47baa7acf 100644
--- a/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java
@@ -133,4 +133,8 @@ public class NotPointcut extends Pointcut {
return ret;
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java
index 4106af216..bfd9dad5e 100644
--- a/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java
@@ -32,7 +32,7 @@ import org.aspectj.weaver.VersionedDataInputStream;
* @author Jim Hugunin
*/
public class NotTypePattern extends TypePattern {
- private TypePattern pattern;
+ TypePattern pattern;
public NotTypePattern(TypePattern pattern) {
super(false,false); //??? we override all methods that care about includeSubtypes
@@ -145,4 +145,8 @@ public class NotTypePattern extends TypePattern {
public int hashCode() {
return 17 + 37 * pattern.hashCode();
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java b/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java
index d5fd12471..12abd441b 100644
--- a/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java
@@ -29,7 +29,7 @@ import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.ast.Test;
public class OrPointcut extends Pointcut {
- private Pointcut left, right;
+ Pointcut left, right;
private Set couldMatchKinds;
public OrPointcut(Pointcut left, Pointcut right) {
@@ -147,4 +147,8 @@ public class OrPointcut extends Pointcut {
public Pointcut getRight() {
return right;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java
index e5e372d80..a23c2fbe7 100644
--- a/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java
@@ -30,7 +30,7 @@ import org.aspectj.weaver.VersionedDataInputStream;
* @author Jim Hugunin
*/
public class OrTypePattern extends TypePattern {
- private TypePattern left, right;
+ TypePattern left, right;
public OrTypePattern(TypePattern left, TypePattern right) {
super(false,false); //??? we override all methods that care about includeSubtypes
@@ -167,4 +167,8 @@ public class OrTypePattern extends TypePattern {
ret = ret + 37 * right.hashCode();
return ret;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternNode.java b/weaver/src/org/aspectj/weaver/patterns/PatternNode.java
index 0730538ca..817064123 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PatternNode.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PatternNode.java
@@ -80,4 +80,8 @@ public abstract class PatternNode implements IHasSourceLocation {
end = s.readInt();
this.sourceContext = context;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java
index c620159f5..0f00b5ab7 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java
@@ -219,7 +219,8 @@ public class PatternParser {
if (maybeEat("||")) {
p = new OrPointcut(p, parsePointcut());
- }
+ }
+
return p;
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java b/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java
new file mode 100644
index 000000000..bddb7efcc
--- /dev/null
+++ b/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Vasseur initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver.patterns;
+
+import org.aspectj.weaver.Member;
+import org.aspectj.weaver.Shadow;
+import org.aspectj.weaver.ResolvedPointcutDefinition;
+import org.aspectj.weaver.ResolvedTypeX;
+import org.aspectj.weaver.World;
+
+/**
+ * A visitor that turns a pointcut into a type pattern equivalent for a perthis or pertarget matching:
+ * - pertarget(target(Foo)) => Foo+ (this one is a special case..)
+ * - pertarget(execution(* Foo.do()) => Foo
+ * - perthis(call(* Foo.do()) => *
+ * - perthis(!call(* Foo.do()) => * (see how the ! has been absorbed here..)
+ *
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class PerThisOrTargetPointcutVisitor extends IdentityPointcutVisitor {
+
+ /** A maybe marker */
+ private final static TypePattern MAYBE = new TypePatternMayBe();
+
+ private final boolean m_isTarget;
+ private final ResolvedTypeX m_fromAspectType;
+
+ public PerThisOrTargetPointcutVisitor(boolean isTarget, ResolvedTypeX fromAspectType) {
+ m_isTarget = isTarget;
+ m_fromAspectType = fromAspectType;
+ }
+
+ public TypePattern getPerTypePointcut(Pointcut perClausePointcut) {
+ return (TypePattern) perClausePointcut.accept(this, perClausePointcut);
+ }
+
+ //-- visitor methods, all is like Identity visitor except when it comes to transform pointcuts
+
+ public Object visit(WithinPointcut node, Object data) {
+ if (m_isTarget) {
+ //pertarget(.. && within(Foo)) => true
+ //pertarget(.. && !within(Foo)) => true as well !
+ return MAYBE;
+ } else {
+ return node.typePattern;
+ }
+ }
+
+ public Object visit(WithincodePointcut node, Object data) {
+ if (m_isTarget) {
+ //pertarget(.. && withincode(* Foo.do())) => true
+ //pertarget(.. && !withincode(* Foo.do())) => true as well !
+ return MAYBE;
+ } else {
+ return node.signature.getDeclaringType();
+ }
+ }
+
+ public Object visit(WithinAnnotationPointcut node, Object data) {
+ if (m_isTarget) {
+ return MAYBE;
+ } else {
+ return node.annotationTypePattern;
+ }
+ }
+
+ public Object visit(WithinCodeAnnotationPointcut node, Object data) {
+ if (m_isTarget) {
+ return MAYBE;
+ } else {
+ return MAYBE;//FIXME AV - can we optimize ? perthis(@withincode(Foo)) = hasmethod(..)
+ }
+ }
+
+ public Object visit(KindedPointcut node, Object data) {
+ if (node.getKind().equals(Shadow.AdviceExecution)) {
+ return MAYBE;//TODO AV - can we do better ?
+ } else if (node.getKind().equals(Shadow.ConstructorExecution)
+ || node.getKind().equals(Shadow.Initialization)
+ || node.getKind().equals(Shadow.MethodExecution)
+ || node.getKind().equals(Shadow.PreInitialization)
+ || node.getKind().equals(Shadow.StaticInitialization)) {
+ return node.signature.getDeclaringType();
+ } else if (node.getKind().equals(Shadow.ConstructorCall)
+ || node.getKind().equals(Shadow.FieldGet)
+ || node.getKind().equals(Shadow.FieldSet)
+ || node.getKind().equals(Shadow.MethodCall)) {
+ if (m_isTarget) {
+ return node.signature.getDeclaringType();
+ } else {
+ return MAYBE;
+ }
+ } else if (node.getKind().equals(Shadow.ExceptionHandler)) {
+ return MAYBE;
+ } else {
+ throw new ParserException("Undetermined - should not happen: " + node.getKind().getSimpleName(), null);
+ }
+ }
+
+ public Object visit(AndPointcut node, Object data) {
+ return new AndTypePattern(getPerTypePointcut(node.left), getPerTypePointcut(node.right));
+ }
+
+ public Object visit(OrPointcut node, Object data) {
+ return new OrTypePattern(getPerTypePointcut(node.left), getPerTypePointcut(node.right));
+ }
+
+ public Object visit(NotPointcut node, Object data) {
+ TypePattern negated = getPerTypePointcut(node.getNegatedPointcut());
+ if (MAYBE.equals(negated)) {
+ return MAYBE;
+ }
+ return new NotTypePattern(negated);
+ }
+
+ public Object visit(ThisOrTargetAnnotationPointcut node, Object data) {
+ if (m_isTarget && !node.isThis()) {
+ return node.annotationTypePattern;
+ } else if (!m_isTarget && node.isThis()) {
+ return node.annotationTypePattern;
+ } else {
+ // perthis(@target(Foo))
+ return MAYBE;
+ }
+ }
+
+ public Object visit(ThisOrTargetPointcut node, Object data) {
+ if ((m_isTarget && !node.isThis())
+ || (!m_isTarget && node.isThis())) {
+ //pertarget(target(Foo)) => Foo+ for type pattern matching
+ //perthis(this(Foo)) => Foo+ for type pattern matching
+ // TODO AV - we do like a deep copy by parsing it again.. quite dirty, would need a clean deep copy
+ TypePattern copy = new PatternParser(node.type.toString()).parseTypePattern();
+ copy.includeSubtypes = true;
+ return copy;
+ } else {
+ // perthis(target(Foo)) => maybe
+ return MAYBE;
+ }
+ }
+
+ public Object visit(ReferencePointcut node, Object data) {
+ // && pc_ref()
+ // we know there is no support for binding in perClause: perthis(pc_ref(java.lang.String))
+ // TODO AV - may need some work for generics..
+
+ ResolvedPointcutDefinition pointcutDec;
+ ResolvedTypeX searchStart = m_fromAspectType;
+ if (node.onType != null) {
+ searchStart = node.onType.resolve(m_fromAspectType.getWorld());
+ if (searchStart == ResolvedTypeX.MISSING) {
+ return MAYBE;// this should not happen since concretize will fails but just in case..
+ }
+ }
+ pointcutDec = searchStart.findPointcut(node.name);
+
+ return getPerTypePointcut(pointcutDec.getPointcut());
+ }
+
+ public Object visit(IfPointcut node, Object data) {
+ return TypePattern.ANY;
+ }
+
+ public Object visit(HandlerPointcut node, Object data) {
+ // quiet unexpected since a KindedPointcut but do as if...
+ return MAYBE;
+ }
+
+ public Object visit(CflowPointcut node, Object data) {
+ return MAYBE;
+ }
+
+ public Object visit(ConcreteCflowPointcut node, Object data) {
+ return MAYBE;
+ }
+
+ public Object visit(ArgsPointcut node, Object data) {
+ return MAYBE;
+ }
+
+ public Object visit(ArgsAnnotationPointcut node, Object data) {
+ return MAYBE;
+ }
+
+ public Object visit(AnnotationPointcut node, Object data) {
+ return MAYBE;
+ }
+
+ public Object visit(Pointcut.MatchesNothingPointcut node, Object data) {
+ // a small hack since the usual MatchNothing has its toString = "<nothing>" which is not parseable back
+ // while I use back parsing for check purpose.
+ return new NoTypePattern() {
+ public String toString() {
+ return "false";
+ }
+ };
+ }
+
+ /**
+ * A MayBe type pattern that acts as ANY except that !MAYBE = MAYBE
+ *
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+ private static class TypePatternMayBe extends AnyTypePattern {
+ }
+}
diff --git a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java
index cc5e86762..886d1af9d 100644
--- a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java
@@ -353,7 +353,7 @@ public abstract class Pointcut extends PatternNode implements PointcutExpression
return parser.parsePointcut();
}
- private static class MatchesNothingPointcut extends Pointcut {
+ static class MatchesNothingPointcut extends Pointcut {
protected Test findResidueInternal(Shadow shadow, ExposedState state) {
return Literal.FALSE; // can only get here if an earlier error occurred
}
@@ -412,6 +412,10 @@ public abstract class Pointcut extends PatternNode implements PointcutExpression
}
public String toString() { return ""; }
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
//public static Pointcut MatchesNothing = new MatchesNothingPointcut();
diff --git a/weaver/src/org/aspectj/weaver/patterns/PointcutVisitor.java b/weaver/src/org/aspectj/weaver/patterns/PointcutVisitor.java
new file mode 100644
index 000000000..9faba4a27
--- /dev/null
+++ b/weaver/src/org/aspectj/weaver/patterns/PointcutVisitor.java
@@ -0,0 +1,623 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Vasseur initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver.patterns;
+
+import org.aspectj.weaver.Member;
+
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+/**
+ * A Pointcut or TypePattern visitor
+ *
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public interface PointcutVisitor {
+
+ Object visit(AnyTypePattern node, Object data);
+
+ Object visit(NoTypePattern node, Object data);
+
+ Object visit(EllipsisTypePattern node, Object data);
+
+ Object visit(AnyWithAnnotationTypePattern node, Object data);
+
+ Object visit(AnyAnnotationTypePattern node, Object data);
+
+ Object visit(EllipsisAnnotationTypePattern node, Object data);
+
+ Object visit(AndAnnotationTypePattern node, Object data);
+
+ Object visit(AndPointcut node, Object data);
+
+ Object visit(AndTypePattern node, Object data);
+
+ Object visit(AnnotationPatternList node, Object data);
+
+ Object visit(AnnotationPointcut node, Object data);
+
+ Object visit(ArgsAnnotationPointcut node, Object data);
+
+ Object visit(ArgsPointcut node, Object data);
+
+ Object visit(BindingAnnotationTypePattern node, Object data);
+
+ Object visit(BindingTypePattern node, Object data);
+
+ Object visit(CflowPointcut node, Object data);
+
+ Object visit(ConcreteCflowPointcut node, Object data);
+
+ Object visit(DeclareAnnotation node, Object data);
+
+ Object visit(DeclareErrorOrWarning node, Object data);
+
+ Object visit(DeclareParents node, Object data);
+
+ Object visit(DeclarePrecedence node, Object data);
+
+ Object visit(DeclareSoft node, Object data);
+
+ Object visit(ExactAnnotationTypePattern node, Object data);
+
+ Object visit(ExactTypePattern node, Object data);
+
+ Object visit(HandlerPointcut node, Object data);
+
+ Object visit(IfPointcut node, Object data);
+
+ Object visit(KindedPointcut node, Object data);
+
+ Object visit(ModifiersPattern node, Object data);
+
+ Object visit(NamePattern node, Object data);
+
+ Object visit(NotAnnotationTypePattern node, Object data);
+
+ Object visit(NotPointcut node, Object data);
+
+ Object visit(NotTypePattern node, Object data);
+
+ Object visit(OrAnnotationTypePattern node, Object data);
+
+ Object visit(OrPointcut node, Object data);
+
+ Object visit(OrTypePattern node, Object data);
+
+ Object visit(PerCflow node, Object data);
+
+ Object visit(PerFromSuper node, Object data);
+
+ Object visit(PerObject node, Object data);
+
+ Object visit(PerSingleton node, Object data);
+
+ Object visit(PerTypeWithin node, Object data);
+
+ Object visit(PatternNode node, Object data);
+
+ Object visit(ReferencePointcut node, Object data);
+
+ Object visit(SignaturePattern node, Object data);
+
+ Object visit(ThisOrTargetAnnotationPointcut node, Object data);
+
+ Object visit(ThisOrTargetPointcut node, Object data);
+
+ Object visit(ThrowsPattern node, Object data);
+
+ Object visit(TypePatternList node, Object data);
+
+ Object visit(WildAnnotationTypePattern node, Object data);
+
+ Object visit(WildTypePattern node, Object data);
+
+ Object visit(WithinAnnotationPointcut node, Object data);
+
+ Object visit(WithinCodeAnnotationPointcut node, Object data);
+
+ Object visit(WithinPointcut node, Object data);
+
+ Object visit(WithincodePointcut node, Object data);
+
+ Object visit(Pointcut.MatchesNothingPointcut node, Object data);
+
+ /**
+ * A sample toString like visitor that helps understanding the AST tree structure organization
+ * TODO: not yet complete
+ *
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+ static class DumpPointcutVisitor implements PointcutVisitor {
+
+ private StringBuffer sb = new StringBuffer();
+ public String get() {
+ return sb.toString();
+ }
+
+ private void p(Object o) {
+ sb.append(o.toString());
+ }
+
+ /**
+ * This method helps maintaining the API and raises warning when PatternNode subclasses do not
+ * implement the visitor pattern
+ *
+ * @param node
+ * @param data
+ * @return
+ */
+ public Object visit(PatternNode node, Object data) {
+ System.err.println("Should implement: " + node.getClass());
+ return null;
+ }
+
+ public Object visit(AnyTypePattern node, Object data) {
+ p('*');
+ return null;
+ }
+
+ public Object visit(NoTypePattern node, Object data) {
+ p(node.toString());//TODO no idea when this one is used
+ return null;
+ }
+
+ public Object visit(EllipsisTypePattern node, Object data) {
+ p(node.toString());
+ return null;
+ }
+
+ public Object visit(AnyWithAnnotationTypePattern node, Object data) {
+ node.annotationPattern.accept(this, data);
+ p(" *");
+ return null;
+ }
+
+ public Object visit(AnyAnnotationTypePattern node, Object data) {
+ //@ANY : ignore
+ return null;
+ }
+
+ public Object visit(EllipsisAnnotationTypePattern node, Object data) {
+ p("..");
+ return null;
+ }
+
+ public Object visit(AndAnnotationTypePattern node, Object data) {
+ p('(');
+ node.getLeft().accept(this, data);
+ p(" && ");
+ node.getRight().accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(AndPointcut node, Object data) {
+ p('(');
+ node.getLeft().accept(this, data);
+ p(" && ");
+ node.getRight().accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(AndTypePattern node, Object data) {
+ p('(');
+ node.left.accept(this, data);
+ p(" && ");
+ node.right.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(AnnotationPatternList node, Object data) {
+ AnnotationTypePattern[] annotations = node.getAnnotationPatterns();
+ for (int i = 0; i < annotations.length; i++) {
+ annotations[i].accept(this, data);
+ p(' ');
+ }
+ return null;
+ }
+
+ public Object visit(AnnotationPointcut node, Object data) {
+ p("@annotation(");
+ node.annotationTypePattern.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(ArgsAnnotationPointcut node, Object data) {
+ p("@args(");
+ node.arguments.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(ArgsPointcut node, Object data) {
+ p("args(");
+ node.arguments.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(BindingAnnotationTypePattern node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(BindingTypePattern node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(CflowPointcut node, Object data) {
+ p(node.isBelow?"cflowbelow(":"cflow(");
+ node.getEntry().accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(ExactAnnotationTypePattern node, Object data) {
+ p('@');
+ p(node.annotationType.getName());
+ return null;
+ }
+
+ public Object visit(ExactTypePattern node, Object data) {
+ if (node.annotationPattern != AnnotationTypePattern.ANY) {
+ p('(');
+ node.annotationPattern.accept(this, data);
+ p(' ');
+ }
+
+ String typeString = node.type.toString();
+ if (node.isVarArgs) typeString = typeString.substring(0, typeString.lastIndexOf('['));//TODO AV - ugly
+ p(typeString);
+ if (node.includeSubtypes) p('+');
+ if (node.isVarArgs) p("...");
+ if (node.annotationPattern != AnnotationTypePattern.ANY) {
+ p(')');
+ }
+ return null;
+ }
+
+ public Object visit(KindedPointcut node, Object data) {
+ p(node.getKind().getSimpleName());
+ p('(');
+ node.signature.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(ModifiersPattern node, Object data) {
+ p(node.toString());//note: node takes care of forbidden mods
+ return null;
+ }
+
+ public Object visit(NamePattern node, Object data) {
+ p(node.toString());
+ return null;
+ }
+
+ public Object visit(NotAnnotationTypePattern node, Object data) {
+ p("!(");
+ node.negatedPattern.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(NotPointcut node, Object data) {
+ p("!(");
+ node.getNegatedPointcut().accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(NotTypePattern node, Object data) {
+ p("!(");
+ node.pattern.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(OrAnnotationTypePattern node, Object data) {
+ p('(');
+ node.getLeft().accept(this, data);
+ p(" || ");
+ node.getRight().accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(OrPointcut node, Object data) {
+ p('(');
+ node.getLeft().accept(this, data);
+ p(" || ");
+ node.getRight().accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(OrTypePattern node, Object data) {
+ p('(');
+ node.left.accept(this, data);
+ p(" || ");
+ node.right.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(ReferencePointcut node, Object data) {
+ p(node.toString());
+ return null;
+ }
+
+ public Object visit(SignaturePattern node, Object data) {
+ if (node.getAnnotationPattern() != AnnotationTypePattern.ANY) {
+ node.getAnnotationPattern().accept(this, data);
+ p(' ');
+ }
+
+ if (node.getModifiers() != ModifiersPattern.ANY) {
+ node.getModifiers().accept(this, data);
+ p(' ');
+ }
+
+ if (node.getKind() == Member.STATIC_INITIALIZATION) {
+ node.getDeclaringType().accept(this, data);
+ p(".<clinit>()");
+ } else if (node.getKind() == Member.HANDLER) {
+ p("handler(");
+ node.getParameterTypes().get(0).accept(this, data);//Note: we know we have 1 child
+ p(')');
+ } else {
+ if (!(node.getKind() == Member.CONSTRUCTOR)) {
+ node.getReturnType().accept(this, data);
+ p(' ');
+ }
+ if (node.getDeclaringType() != TypePattern.ANY) {
+ node.getDeclaringType().accept(this, data);
+ p('.');
+ }
+ if (node.getKind() == Member.CONSTRUCTOR) {
+ p("new");
+ } else {
+ node.getName().accept(this, data);
+ }
+ if (node.getKind() == Member.METHOD || node.getKind() == Member.CONSTRUCTOR) {
+ p('(');
+ node.getParameterTypes().accept(this, data);
+ p(')');
+ }
+ if (node.getThrowsPattern() != null) {
+ p(' ');
+ node.getThrowsPattern().accept(this, data);
+ }
+ }
+ return null;
+ }
+
+ public Object visit(ThisOrTargetAnnotationPointcut node, Object data) {
+ p(node.isThis() ? "@this(" : "@target(");
+ node.annotationTypePattern.accept(this, data);
+ //buf.append(annPatt.startsWith("@") ? annPatt.substring(1) : annPatt);
+ p(')');
+ return null;
+ }
+
+ public Object visit(ThisOrTargetPointcut node, Object data) {
+ p(node.isThis() ? "this(" : "target(");
+ node.type.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ private boolean inThrowsForbidden = false;
+
+ public Object visit(ThrowsPattern node, Object data) {
+ if (node == ThrowsPattern.ANY) return null;
+
+ p("throws ");
+ node.required.accept(this, data);
+ if (node.forbidden.size() > 0) {
+ // a hack since throws !(A, B) cannot be parsed
+ inThrowsForbidden = true;
+ node.forbidden.accept(this, data);
+ inThrowsForbidden = false;
+ }
+ return null;
+ }
+
+ public Object visit(TypePatternList node, Object data) {
+ if (node.getTypePatterns().length == 0) return null;
+
+ TypePattern[] typePatterns = node.getTypePatterns();
+ for (int i = 0; i < typePatterns.length; i++) {
+ TypePattern typePattern = typePatterns[i];
+ if (i > 0) p(", ");
+ if (inThrowsForbidden) p('!');
+ typePattern.accept(this, data);
+ }
+ return null;
+ }
+
+ public Object visit(WildAnnotationTypePattern node, Object data) {
+ p("@(");
+ node.typePattern.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(WildTypePattern node, Object data) {
+ if (node.annotationPattern != AnnotationTypePattern.ANY) {
+ p('(');
+ node.annotationPattern.accept(this, data);
+ p(' ');
+ }
+ for (int i=0, len=node.namePatterns.length; i < len; i++) {
+ NamePattern name = node.namePatterns[i];
+ if (name == null) {
+ p('.');//FIXME mh, error prone, can't we have a nullNamePattern ?
+ } else {
+ if (i > 0) p('.');
+ name.accept(this, data);
+ }
+ }
+ if (node.includeSubtypes) p('+');
+ if (node.isVarArgs) p("...");//FIXME ? in type pattern
+ if (node.annotationPattern != AnnotationTypePattern.ANY) {
+ p(')');
+ }
+ return null;
+ }
+
+ public Object visit(WithinAnnotationPointcut node, Object data) {
+ p("@within(");
+ node.annotationTypePattern.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(WithinCodeAnnotationPointcut node, Object data) {
+ p("@withincode(");
+ node.annotationTypePattern.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(WithinPointcut node, Object data) {
+ p("within(");
+ node.typePattern.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(WithincodePointcut node, Object data) {
+ p("withincode(");
+ node.signature.accept(this, data);
+ p(')');
+ return null;
+ }
+
+ public Object visit(Pointcut.MatchesNothingPointcut node, Object data) {
+ p("");//TODO shouldn't that be a "false" ?
+ return null;
+ }
+
+
+ //-------------- perX
+
+ public Object visit(PerCflow node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(PerFromSuper node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(PerObject node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(PerSingleton node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(PerTypeWithin node, Object data) {
+ p(node);
+ return null;
+ }
+
+ // ------------- declare X
+
+ public Object visit(DeclareAnnotation node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(DeclareErrorOrWarning node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(DeclareParents node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(DeclarePrecedence node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(DeclareSoft node, Object data) {
+ p(node);
+ return null;
+ }
+
+ // ----------- misc
+
+ public Object visit(ConcreteCflowPointcut node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(HandlerPointcut node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public Object visit(IfPointcut node, Object data) {
+ p(node);
+ return null;
+ }
+
+ public static void check(String s) {
+ check(Pointcut.fromString(s), false);
+ }
+
+ public static void check(PatternNode pc, boolean isTypePattern) {
+ DumpPointcutVisitor v1 = new DumpPointcutVisitor();
+ pc.accept(v1, null);
+
+ DumpPointcutVisitor v2 = new DumpPointcutVisitor();
+ final PatternNode pc2;
+ if (isTypePattern) {
+ pc2 = new PatternParser(v1.get()).parseTypePattern();
+ } else {
+ pc2 = Pointcut.fromString(v1.get());
+ }
+ pc2.accept(v2, null);
+
+ // at second parsing, the String form stay stable when parsed and parsed again
+ if (! v1.get().equals(v2.get())) {
+ throw new ParserException("Unstable back parsing for '"+pc+"', got '" + v1.get() + "' and '" + v2.get() + "'", null);
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ String s = "execution(* foo.bar.do() throws !(@An Waza), !Bla)";
+ check(s);
+ }
+
+ }
+
+}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
index c510cf5be..1b18cced8 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
@@ -312,5 +312,7 @@ public class ReferencePointcut extends Pointcut {
return result;
}
-
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
index 13f8be048..0b0e4d980 100644
--- a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
@@ -512,6 +512,7 @@ public class SignaturePattern extends PatternNode {
if (kind == Member.METHOD || kind == Member.CONSTRUCTOR) {
buf.append(parameterTypes.toString());
}
+ //FIXME AV - throws is not printed here, weird
}
return buf.toString();
}
@@ -624,4 +625,7 @@ public class SignaturePattern extends PatternNode {
return annotationPattern == AnnotationTypePattern.ANY;
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
index 590c022d3..9310cfe60 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
@@ -43,7 +43,7 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
private boolean isThis;
private boolean alreadyWarnedAboutDEoW = false;
- private ExactAnnotationTypePattern annotationTypePattern;
+ ExactAnnotationTypePattern annotationTypePattern;
private ShadowMunger munger;
private static final Set thisKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
private static final Set targetKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
@@ -266,4 +266,8 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
buf.append(")");
return buf.toString();
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java
index 8c3dcccfd..f1bb005a3 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java
@@ -53,7 +53,7 @@ import org.aspectj.weaver.ast.Var;
*/
public class ThisOrTargetPointcut extends NameBindingPointcut {
private boolean isThis;
- private TypePattern type;
+ TypePattern type;
private static final Set thisKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
private static final Set targetKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
@@ -228,4 +228,7 @@ public class ThisOrTargetPointcut extends NameBindingPointcut {
return ret;
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java b/weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java
index ea66f5900..a0e7fd244 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java
@@ -24,8 +24,8 @@ import org.aspectj.weaver.World;
public class ThrowsPattern extends PatternNode {
- private TypePatternList required;
- private TypePatternList forbidden;
+ TypePatternList required;
+ TypePatternList forbidden;
public static final ThrowsPattern ANY =
new ThrowsPattern(TypePatternList.EMPTY, TypePatternList.EMPTY);
@@ -143,4 +143,8 @@ public class ThrowsPattern extends PatternNode {
forbidden.write(s);
//XXXwriteLocation(s);
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java
index dd33ef30a..06a5d3069 100644
--- a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java
@@ -389,6 +389,12 @@ class EllipsisTypePattern extends TypePattern {
public int hashCode() {
return 17 * 37;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
+
}
class AnyTypePattern extends TypePattern {
@@ -473,6 +479,10 @@ class AnyTypePattern extends TypePattern {
public int hashCode() {
return 37;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
/**
@@ -620,7 +630,7 @@ class NoTypePattern extends TypePattern {
return false;
}
- public String toString() { return "<nothing>"; }
+ public String toString() { return "<nothing>"; }//FIXME AV - bad! toString() cannot be parsed back (not idempotent)
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
@@ -635,5 +645,9 @@ class NoTypePattern extends TypePattern {
public int hashCode() {
return 17 * 37 * 37;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java b/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java
index 67dff9dc1..67327aa3d 100644
--- a/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java
+++ b/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java
@@ -503,4 +503,7 @@ public class TypePatternList extends PatternNode {
return ret;
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
index 9019954e2..6e23a430c 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
@@ -31,7 +31,7 @@ import org.aspectj.weaver.World;
*/
public class WildAnnotationTypePattern extends AnnotationTypePattern {
- private TypePattern typePattern;
+ TypePattern typePattern;
private boolean resolved = false;
/**
@@ -138,4 +138,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
public String toString() {
return "@(" + typePattern.toString() + ")";
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
index fd2ec4896..065021651 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
@@ -686,4 +686,8 @@ public class WildTypePattern extends TypePattern {
return ret;
}
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
index cbcf0e55b..c697eb633 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
@@ -41,7 +41,7 @@ import org.aspectj.weaver.ast.Var;
*/
public class WithinAnnotationPointcut extends NameBindingPointcut {
- private AnnotationTypePattern annotationTypePattern;
+ AnnotationTypePattern annotationTypePattern;
private ShadowMunger munger;
/**
@@ -204,4 +204,8 @@ public class WithinAnnotationPointcut extends NameBindingPointcut {
buf.append(")");
return buf.toString();
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java
index edcc5b398..a570ea221 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java
@@ -42,7 +42,7 @@ import org.aspectj.weaver.ast.Var;
*/
public class WithinCodeAnnotationPointcut extends NameBindingPointcut {
- private ExactAnnotationTypePattern annotationTypePattern;
+ ExactAnnotationTypePattern annotationTypePattern;
private ShadowMunger munger = null; // only set after concretization
private static final Set matchedShadowKinds = new HashSet();
static {
@@ -211,4 +211,8 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut {
buf.append(")");
return buf.toString();
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java
index 5e043d438..3a24fce12 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java
@@ -169,4 +169,8 @@ public class WithinPointcut extends Pointcut {
ret.copyLocationFrom(this);
return ret;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java
index 326567be3..5aed14d77 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java
@@ -134,4 +134,8 @@ public class WithincodePointcut extends Pointcut {
ret.copyLocationFrom(this);
return ret;
}
+
+ public Object accept(PointcutVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}