summaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher/src/org
diff options
context:
space:
mode:
authoraclement <aclement>2009-10-30 23:12:27 +0000
committeraclement <aclement>2009-10-30 23:12:27 +0000
commitc27d7376e3911bf2a26638822edf8fa747817b8b (patch)
treeba4658413363d338e81d0f2ec1aeafc68d40257b /org.aspectj.matcher/src/org
parent9094be08c33dc986994145a78d091cdb81c90de8 (diff)
downloadaspectj-c27d7376e3911bf2a26638822edf8fa747817b8b.tar.gz
aspectj-c27d7376e3911bf2a26638822edf8fa747817b8b.zip
formatted
Diffstat (limited to 'org.aspectj.matcher/src/org')
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java203
1 files changed, 121 insertions, 82 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
index ba9ce8b26..1003a475b 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
@@ -35,17 +35,17 @@ import org.aspectj.weaver.ast.Var;
/**
* @author colyer
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
+ *
+ * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code
+ * Templates
*/
public class WithinAnnotationPointcut extends NameBindingPointcut {
private AnnotationTypePattern annotationTypePattern;
private String declarationText;
-
+
/**
- *
+ *
*/
public WithinAnnotationPointcut(AnnotationTypePattern type) {
super();
@@ -53,119 +53,146 @@ public class WithinAnnotationPointcut extends NameBindingPointcut {
this.pointcutKind = ATWITHIN;
buildDeclarationText();
}
-
+
public WithinAnnotationPointcut(AnnotationTypePattern type, ShadowMunger munger) {
- this(type);
- this.pointcutKind = ATWITHIN;
+ this(type);
+ this.pointcutKind = ATWITHIN;
}
- public AnnotationTypePattern getAnnotationTypePattern() {
- return annotationTypePattern;
- }
+ public AnnotationTypePattern getAnnotationTypePattern() {
+ return annotationTypePattern;
+ }
+ @Override
public int couldMatchKinds() {
return Shadow.ALL_SHADOW_KINDS_BITS;
}
-
- public Pointcut parameterizeWith(Map typeVariableMap,World w) {
- WithinAnnotationPointcut ret = new WithinAnnotationPointcut(this.annotationTypePattern.parameterizeWith(typeVariableMap,w));
+
+ @Override
+ public Pointcut parameterizeWith(Map typeVariableMap, World w) {
+ WithinAnnotationPointcut ret = new WithinAnnotationPointcut(this.annotationTypePattern.parameterizeWith(typeVariableMap, w));
ret.copyLocationFrom(this);
return ret;
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.aspectj.weaver.patterns.Pointcut#fastMatch(org.aspectj.weaver.patterns.FastMatchInfo)
*/
+ @Override
public FuzzyBoolean fastMatch(FastMatchInfo info) {
- return annotationTypePattern.fastMatches(info.getType());
+ return annotationTypePattern.fastMatches(info.getType());
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.aspectj.weaver.patterns.Pointcut#match(org.aspectj.weaver.Shadow)
*/
+ @Override
protected FuzzyBoolean matchInternal(Shadow shadow) {
- ResolvedType enclosingType = shadow.getIWorld().resolve(shadow.getEnclosingType(),true);
+ ResolvedType enclosingType = shadow.getIWorld().resolve(shadow.getEnclosingType(), true);
if (enclosingType.isMissing()) {
- shadow.getIWorld().getLint().cantFindType.signal(
- new String[] {WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_WITHINPCD,
- shadow.getEnclosingType().getName())},
- shadow.getSourceLocation(),
- new ISourceLocation[]{getSourceLocation()});
-// IMessage msg = new Message(
-// WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_WITHINPCD,
-// shadow.getEnclosingType().getName()),
-// shadow.getSourceLocation(),true,new ISourceLocation[]{getSourceLocation()});
-// shadow.getIWorld().getMessageHandler().handleMessage(msg);
+ shadow.getIWorld().getLint().cantFindType.signal(new String[] { WeaverMessages.format(
+ WeaverMessages.CANT_FIND_TYPE_WITHINPCD, shadow.getEnclosingType().getName()) }, shadow.getSourceLocation(),
+ new ISourceLocation[] { getSourceLocation() });
+ // IMessage msg = new Message(
+ // WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_WITHINPCD,
+ // shadow.getEnclosingType().getName()),
+ // shadow.getSourceLocation(),true,new ISourceLocation[]{getSourceLocation()});
+ // shadow.getIWorld().getMessageHandler().handleMessage(msg);
}
annotationTypePattern.resolve(shadow.getIWorld());
return annotationTypePattern.matches(enclosingType);
}
- /* (non-Javadoc)
- * @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope,
+ * org.aspectj.weaver.patterns.Bindings)
*/
+ @Override
protected void resolveBindings(IScope scope, Bindings bindings) {
if (!scope.getWorld().isInJava5Mode()) {
scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.ATWITHIN_ONLY_SUPPORTED_AT_JAVA5_LEVEL),
getSourceLocation()));
return;
}
- annotationTypePattern = annotationTypePattern.resolveBindings(scope,bindings,true);
+ annotationTypePattern = annotationTypePattern.resolveBindings(scope, bindings, true);
// must be either a Var, or an annotation type pattern
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.aspectj.weaver.patterns.Pointcut#concretize1(org.aspectj.weaver.ResolvedType, org.aspectj.weaver.IntMap)
*/
+ @Override
protected Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) {
- ExactAnnotationTypePattern newType = (ExactAnnotationTypePattern) annotationTypePattern.remapAdviceFormals(bindings);
+ ExactAnnotationTypePattern newType = (ExactAnnotationTypePattern) annotationTypePattern.remapAdviceFormals(bindings);
Pointcut ret = new WithinAnnotationPointcut(newType, bindings.getEnclosingAdvice());
- ret.copyLocationFrom(this);
- return ret;
+ ret.copyLocationFrom(this);
+ return ret;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.aspectj.weaver.patterns.Pointcut#findResidue(org.aspectj.weaver.Shadow, org.aspectj.weaver.patterns.ExposedState)
*/
+ @Override
protected Test findResidueInternal(Shadow shadow, ExposedState state) {
if (annotationTypePattern instanceof BindingAnnotationTypePattern) {
- BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern)annotationTypePattern;
+ BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) annotationTypePattern;
UnresolvedType annotationType = btp.annotationType;
Var var = shadow.getWithinAnnotationVar(annotationType);
-
- // This should not happen, we shouldn't have gotten this far
+
+ // This should not happen, we shouldn't have gotten this far
// if we weren't going to find the annotation
- if (var == null)
- throw new BCException("Impossible! annotation=["+annotationType+
- "] shadow=["+shadow+" at "+shadow.getSourceLocation()+
- "] pointcut is at ["+getSourceLocation()+"]");
-
- state.set(btp.getFormalIndex(),var);
- }
+ if (var == null) {
+ throw new BCException("Impossible! annotation=[" + annotationType + "] shadow=[" + shadow + " at "
+ + shadow.getSourceLocation() + "] pointcut is at [" + getSourceLocation() + "]");
+ }
+
+ state.set(btp.getFormalIndex(), var);
+ }
return match(shadow).alwaysTrue() ? Literal.TRUE : Literal.FALSE;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.aspectj.weaver.patterns.NameBindingPointcut#getBindingAnnotationTypePatterns()
*/
+ @Override
public List getBindingAnnotationTypePatterns() {
if (annotationTypePattern instanceof BindingAnnotationTypePattern) {
List l = new ArrayList();
l.add(annotationTypePattern);
return l;
- } else return Collections.EMPTY_LIST;
+ } else {
+ return Collections.EMPTY_LIST;
+ }
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.aspectj.weaver.patterns.NameBindingPointcut#getBindingTypePatterns()
*/
+ @Override
public List getBindingTypePatterns() {
return Collections.EMPTY_LIST;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream)
*/
+ @Override
public void write(DataOutputStream s) throws IOException {
s.writeByte(Pointcut.ATWITHIN);
annotationTypePattern.write(s);
@@ -178,40 +205,52 @@ public class WithinAnnotationPointcut extends NameBindingPointcut {
ret.readLocation(context, s);
return ret;
}
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (!(obj instanceof WithinAnnotationPointcut)) return false;
- WithinAnnotationPointcut other = (WithinAnnotationPointcut) obj;
- return other.annotationTypePattern.equals(this.annotationTypePattern);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return 17 + 19*annotationTypePattern.hashCode();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- private void buildDeclarationText() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof WithinAnnotationPointcut)) {
+ return false;
+ }
+ WithinAnnotationPointcut other = (WithinAnnotationPointcut) obj;
+ return other.annotationTypePattern.equals(this.annotationTypePattern);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return 17 + 19 * annotationTypePattern.hashCode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ private void buildDeclarationText() {
StringBuffer buf = new StringBuffer();
buf.append("@within(");
String annPatt = annotationTypePattern.toString();
buf.append(annPatt.startsWith("@") ? annPatt.substring(1) : annPatt);
buf.append(")");
this.declarationText = buf.toString();
- }
-
- public String toString() {
- return this.declarationText;
- }
-
- public Object accept(PatternNodeVisitor visitor, Object data) {
- return visitor.visit(this, data);
- }
+ }
+
+ @Override
+ public String toString() {
+ return this.declarationText;
+ }
+
+ @Override
+ public Object accept(PatternNodeVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
}