]> source.dussan.org Git - aspectj.git/commitdiff
319190: AND precedence over OR
authoraclement <aclement>
Wed, 7 Jul 2010 21:01:58 +0000 (21:01 +0000)
committeraclement <aclement>
Wed, 7 Jul 2010 21:01:58 +0000 (21:01 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java

index 50c38cc225fe47c217f99d793aff5aac57020133..2cc6d20369ab989ef9db78e3913273438e8f7f81 100644 (file)
@@ -1,6 +1,5 @@
 /* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- *               2005 Contributors
+ * Copyright (c) 2002,2010
  * All rights reserved. 
  * This program and the accompanying materials are made available 
  * under the terms of the Eclipse Public License v1.0 
@@ -9,7 +8,8 @@
  *  
  * Contributors: 
  *     PARC     initial implementation
- *     Adrian Colyer many updates since.... 
+ *     Adrian Colyer, IBM
+ *     Andy Clement, IBM, SpringSource
  * ******************************************************************/
 
 package org.aspectj.weaver.patterns;
@@ -31,7 +31,12 @@ import org.aspectj.weaver.internal.tools.PointcutDesignatorHandlerBasedPointcut;
 import org.aspectj.weaver.tools.ContextBasedMatcher;
 import org.aspectj.weaver.tools.PointcutDesignatorHandler;
 
-//XXX doesn't handle errors for extra tokens very well (sometimes ignores)
+/**
+ * @author PARC
+ * @author Adrian Colyer
+ * @author Andy Clement
+ */
+// XXX doesn't handle errors for extra tokens very well (sometimes ignores)
 public class PatternParser {
 
        private ITokenSource tokenSource;
@@ -140,8 +145,8 @@ public class PatternParser {
                        ret = parseSoft();
                } else {
                        throw new ParserException(
-                                       "expected one of error, warning, parents, soft, precedence, @type, @method, @constructor, @field", tokenSource
-                                                       .peek(-1));
+                                       "expected one of error, warning, parents, soft, precedence, @type, @method, @constructor, @field",
+                                       tokenSource.peek(-1));
                }
                int endPos = tokenSource.peek(-1).getEnd();
                ret.setLocation(sourceContext, startPos, endPos);
@@ -326,7 +331,7 @@ public class PatternParser {
        private Pointcut parseNotOrPointcut() {
                Pointcut p = parseAtomicPointcut();
                if (maybeEat("&&")) {
-                       p = new AndPointcut(p, parsePointcut());
+                       p = new AndPointcut(p, parseNotOrPointcut());
                }
                return p;
        }
@@ -1108,7 +1113,7 @@ public class PatternParser {
        // if (maybeEat("&&")) {
        // ap = new AndAnnotationTypePattern(ap, parseNotOrAnnotationPattern());
        // }
-       //              
+       //
        // if (maybeEat("||")) {
        // ap = new OrAnnotationTypePattern(ap, parseAnnotationTypePattern());
        // }
index b9dfc90483f311164dfd6d52b254fba72e051a4c..f927286ecd71004f8debc0d16def74dc3fbb6a83 100644 (file)
@@ -28,6 +28,7 @@ import org.aspectj.weaver.PoliceExtensionUse;
 import org.aspectj.weaver.ResolvedType;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.ShadowMunger;
+import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.VersionedDataInputStream;
 import org.aspectj.weaver.World;
 import org.aspectj.weaver.ast.Literal;
@@ -411,7 +412,7 @@ public abstract class Pointcut extends PatternNode {
                }
 
                @Override
-               public Pointcut parameterizeWith(Map typeVariableMap, World w) {
+               public Pointcut parameterizeWith(Map<String, UnresolvedType> typeVariableMap, World w) {
                        return this;
                }
        }
@@ -430,6 +431,6 @@ public abstract class Pointcut extends PatternNode {
                }
        }
 
-       public abstract Pointcut parameterizeWith(Map typeVariableMap, World w);
+       public abstract Pointcut parameterizeWith(Map<String, UnresolvedType> typeVariableMap, World w);
 
 }
index b321382f47c48d1e10507d9dad48857608e9d01c..6888ff2f787cbf7a63c145b8c5a48e7fc4207ef2 100644 (file)
@@ -37,7 +37,6 @@ import org.aspectj.weaver.ast.Test;
 
 /**
  */
-
 // XXX needs check that arguments contains no WildTypePatterns
 public class ReferencePointcut extends Pointcut {
        public UnresolvedType onType;
@@ -48,7 +47,7 @@ public class ReferencePointcut extends Pointcut {
        /**
         * if this is non-null then when the pointcut is concretized the result will be parameterized too.
         */
-       private Map typeVariableMap;
+       private Map<String, UnresolvedType> typeVariableMap;
 
        // public ResolvedPointcut binding;
 
@@ -198,7 +197,7 @@ public class ReferencePointcut extends Pointcut {
                        if (onType.isParameterizedType()) {
                                // build a type map mapping type variable names in the generic type to
                                // the type parameters presented
-                               typeVariableMap = new HashMap();
+                               typeVariableMap = new HashMap<String, UnresolvedType>();
                                ResolvedType underlyingGenericType = ((ResolvedType) onType).getGenericType();
                                TypeVariable[] tVars = underlyingGenericType.getTypeVariables();
                                ResolvedType[] typeParams = ((ResolvedType) onType).getResolvedTypeParameters();
@@ -256,8 +255,11 @@ public class ReferencePointcut extends Pointcut {
        public Pointcut concretize1(ResolvedType searchStart, ResolvedType declaringType, IntMap bindings) {
                if (concretizing) {
                        // Thread.currentThread().dumpStack();
-                       searchStart.getWorld().getMessageHandler().handleMessage(
-                                       MessageUtil.error(WeaverMessages.format(WeaverMessages.CIRCULAR_POINTCUT, this), getSourceLocation()));
+                       searchStart
+                                       .getWorld()
+                                       .getMessageHandler()
+                                       .handleMessage(
+                                                       MessageUtil.error(WeaverMessages.format(WeaverMessages.CIRCULAR_POINTCUT, this), getSourceLocation()));
                        Pointcut p = Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                        p.sourceContext = sourceContext;
                        return p;
@@ -300,10 +302,13 @@ public class ReferencePointcut extends Pointcut {
                        if (!foundMatchingPointcut) {
                                pointcutDec = searchStart.findPointcut(name);
                                if (pointcutDec == null) {
-                                       searchStart.getWorld().getMessageHandler().handleMessage(
-                                                       MessageUtil.error(
-                                                                       WeaverMessages.format(WeaverMessages.CANT_FIND_POINTCUT, name, searchStart.getName()),
-                                                                       getSourceLocation()));
+                                       searchStart
+                                                       .getWorld()
+                                                       .getMessageHandler()
+                                                       .handleMessage(
+                                                                       MessageUtil.error(
+                                                                                       WeaverMessages.format(WeaverMessages.CANT_FIND_POINTCUT, name, searchStart.getName()),
+                                                                                       getSourceLocation()));
                                        return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                                }
                        }
@@ -339,7 +344,7 @@ public class ReferencePointcut extends Pointcut {
                        if (searchStart.isParameterizedType()) {
                                // build a type map mapping type variable names in the generic type to
                                // the type parameters presented
-                               typeVariableMap = new HashMap();
+                               typeVariableMap = new HashMap<String, UnresolvedType>();
                                ResolvedType underlyingGenericType = searchStart.getGenericType();
                                TypeVariable[] tVars = underlyingGenericType.getTypeVariables();
                                ResolvedType[] typeParams = searchStart.getResolvedTypeParameters();
@@ -371,7 +376,7 @@ public class ReferencePointcut extends Pointcut {
         * do this at the point in time this method will be called, so we make a version that will parameterize the pointcut it
         * ultimately resolves to.
         */
-       public Pointcut parameterizeWith(Map typeVariableMap, World w) {
+       public Pointcut parameterizeWith(Map<String, UnresolvedType> typeVariableMap, World w) {
                ReferencePointcut ret = new ReferencePointcut(onType, name, arguments);
                ret.onTypeSymbolic = onTypeSymbolic;
                ret.typeVariableMap = typeVariableMap;