From 78f3cea0b721fee69e57f6b5d5ccb810bcd53ad2 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 7 Jul 2010 21:01:58 +0000 Subject: [PATCH] 319190: AND precedence over OR --- .../weaver/patterns/PatternParser.java | 21 +++++++++------ .../org/aspectj/weaver/patterns/Pointcut.java | 5 ++-- .../weaver/patterns/ReferencePointcut.java | 27 +++++++++++-------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java index 50c38cc22..2cc6d2036 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java @@ -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()); // } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java index b9dfc9048..f927286ec 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java @@ -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 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 typeVariableMap, World w); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java index b321382f4..6888ff2f7 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java @@ -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 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(); 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(); 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 typeVariableMap, World w) { ReferencePointcut ret = new ReferencePointcut(onType, name, arguments); ret.onTypeSymbolic = onTypeSymbolic; ret.typeVariableMap = typeVariableMap; -- 2.39.5