Browse Source

319190: AND precedence over OR

tags/V1_6_10RC1
aclement 14 years ago
parent
commit
78f3cea0b7

+ 13
- 8
org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java View 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());
// }

+ 3
- 2
org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java View 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);

}

+ 16
- 11
org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java View 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;

Loading…
Cancel
Save