summaryrefslogtreecommitdiffstats
path: root/weaver/src
diff options
context:
space:
mode:
authoraclement <aclement>2008-01-25 19:07:33 +0000
committeraclement <aclement>2008-01-25 19:07:33 +0000
commitf6b4f77bf3da486eda54b2b81e433f8a8cf63df1 (patch)
treeb62ade0fb774cb40a122091f5a54c75004b49ebc /weaver/src
parentd33ae8fd19e783c8119cc2519589272ba90a802e (diff)
downloadaspectj-f6b4f77bf3da486eda54b2b81e433f8a8cf63df1.tar.gz
aspectj-f6b4f77bf3da486eda54b2b81e433f8a8cf63df1.zip
paramannos: aware of parameter annotation matching
Diffstat (limited to 'weaver/src')
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java39
1 files changed, 29 insertions, 10 deletions
diff --git a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
index 35c18bc3d..2aa7c51f1 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
@@ -23,6 +23,7 @@ import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.WeaverMessages;
import org.aspectj.weaver.World;
+import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
/**
* @author colyer
@@ -52,17 +53,30 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
* @see org.aspectj.weaver.patterns.AnnotationTypePattern#matches(org.aspectj.weaver.AnnotatedElement)
*/
public FuzzyBoolean matches(AnnotatedElement annotated) {
+ return matches(annotated,null);
+ }
+
+ public FuzzyBoolean matches(AnnotatedElement annotated,ResolvedType[] parameterAnnotations) {
if (!resolved) {
throw new IllegalStateException("Can't match on an unresolved annotation type pattern");
}
- // matches if the type of any of the annotations on the AnnotatedElement is
- // matched by the typePattern.
- ResolvedType[] annTypes = annotated.getAnnotationTypes();
-
- if (annTypes!=null && annTypes.length!=0) {
- for (int i = 0; i < annTypes.length; i++) {
- if (typePattern.matches(annTypes[i],TypePattern.STATIC).alwaysTrue()) {
- return FuzzyBoolean.YES;
+ if (isForParameterAnnotationMatch()) {
+ if (parameterAnnotations!=null && parameterAnnotations.length!=0) {
+ for (int i = 0; i < parameterAnnotations.length; i++) {
+ if (typePattern.matches(parameterAnnotations[i],TypePattern.STATIC).alwaysTrue()) {
+ return FuzzyBoolean.YES;
+ }
+ }
+ }
+ } else {
+ // matches if the type of any of the annotations on the AnnotatedElement is
+ // matched by the typePattern.
+ ResolvedType[] annTypes = annotated.getAnnotationTypes();
+ if (annTypes!=null && annTypes.length!=0) {
+ for (int i = 0; i < annTypes.length; i++) {
+ if (typePattern.matches(annTypes[i],TypePattern.STATIC).alwaysTrue()) {
+ return FuzzyBoolean.YES;
+ }
}
}
}
@@ -102,6 +116,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
}
ExactAnnotationTypePattern eatp = new ExactAnnotationTypePattern(et.getExactType().resolve(scope.getWorld()));
eatp.copyLocationFrom(this);
+ if (isForParameterAnnotationMatch()) eatp.setForParameterAnnotationMatch();
return eatp;
} else {
return this;
@@ -124,6 +139,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
s.writeByte(VERSION);
typePattern.write(s);
writeLocation(s);
+ s.writeBoolean(isForParameterAnnotationMatch());
}
public static AnnotationTypePattern read(VersionedDataInputStream s,ISourceContext context) throws IOException {
@@ -135,6 +151,9 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
TypePattern t = TypePattern.read(s,context);
ret = new WildAnnotationTypePattern(t);
ret.readLocation(context,s);
+ if (s.getMajorVersion()>=WeaverVersionInfo.WEAVER_VERSION_MINOR_AJ160) {
+ if (s.readBoolean()) ret.setForParameterAnnotationMatch();
+ }
return ret;
}
@@ -144,14 +163,14 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
public boolean equals(Object obj) {
if (!(obj instanceof WildAnnotationTypePattern)) return false;
WildAnnotationTypePattern other = (WildAnnotationTypePattern) obj;
- return other.typePattern.equals(typePattern);
+ return other.typePattern.equals(typePattern) && this.isForParameterAnnotationMatch()==other.isForParameterAnnotationMatch();
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
- return 17 + 37*typePattern.hashCode();
+ return (17 + 37*typePattern.hashCode())*37+(isForParameterAnnotationMatch()?0:1);
}
/* (non-Javadoc)