]> source.dussan.org Git - aspectj.git/commitdiff
formatted - and pass world to FastMatchInfo
authoraclement <aclement>
Mon, 2 Nov 2009 21:32:18 +0000 (21:32 +0000)
committeraclement <aclement>
Mon, 2 Nov 2009 21:32:18 +0000 (21:32 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/internal/tools/PointcutExpressionImpl.java

index 29f8e027c92df2cd5bafcbeec2c146547b70987e..fd3581947a44736cd6ae0fad1058f1f6bfe275c0 100644 (file)
@@ -46,44 +46,48 @@ import org.aspectj.weaver.tools.ShadowMatch;
  * Map from weaver.tools interface to internal Pointcut implementation...
  */
 public class PointcutExpressionImpl implements PointcutExpression {
-       
+
        private World world;
        private Pointcut pointcut;
        private String expression;
        private PointcutParameter[] parameters;
        private MatchingContext matchContext = new DefaultMatchingContext();
-       
+
        public PointcutExpressionImpl(Pointcut pointcut, String expression, PointcutParameter[] params, World inWorld) {
                this.pointcut = pointcut;
                this.expression = expression;
                this.world = inWorld;
                this.parameters = params;
-               if (this.parameters == null) this.parameters = new PointcutParameter[0];
+               if (this.parameters == null) {
+                       this.parameters = new PointcutParameter[0];
+               }
        }
-       
+
        public Pointcut getUnderlyingPointcut() {
                return this.pointcut;
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.aspectj.weaver.tools.PointcutExpression#setMatchingContext(org.aspectj.weaver.tools.MatchingContext)
         */
        public void setMatchingContext(MatchingContext aMatchContext) {
                this.matchContext = aMatchContext;
        }
-       
+
        public boolean couldMatchJoinPointsInType(Class aClass) {
                ResolvedType matchType = world.resolve(aClass.getName());
-               ReflectionFastMatchInfo info = new ReflectionFastMatchInfo(matchType,null,this.matchContext);
+               ReflectionFastMatchInfo info = new ReflectionFastMatchInfo(matchType, null, this.matchContext, world);
                return pointcut.fastMatch(info).maybeTrue();
        }
-       
+
        public boolean mayNeedDynamicTest() {
                HasPossibleDynamicContentVisitor visitor = new HasPossibleDynamicContentVisitor();
                pointcut.traverse(visitor, null);
                return visitor.hasDynamicContent();
        }
-       
+
        private ExposedState getExposedState() {
                return new ExposedState(parameters.length);
        }
@@ -91,85 +95,85 @@ public class PointcutExpressionImpl implements PointcutExpression {
        public ShadowMatch matchesMethodExecution(Method aMethod) {
                return matchesExecution(aMethod);
        }
-       
+
        public ShadowMatch matchesConstructorExecution(Constructor aConstructor) {
                return matchesExecution(aConstructor);
        }
-       
+
        private ShadowMatch matchesExecution(Member aMember) {
-               Shadow s = ReflectionShadow.makeExecutionShadow(world, aMember,this.matchContext);
+               Shadow s = ReflectionShadow.makeExecutionShadow(world, aMember, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aMember);
                sm.setWithinCode(null);
                sm.setWithinType(aMember.getDeclaringClass());
                return sm;
        }
-       
+
        public ShadowMatch matchesStaticInitialization(Class aClass) {
-               Shadow s = ReflectionShadow.makeStaticInitializationShadow(world, aClass,this.matchContext);
+               Shadow s = ReflectionShadow.makeStaticInitializationShadow(world, aClass, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(null);
                sm.setWithinCode(null);
                sm.setWithinType(aClass);
                return sm;
-       }       
-       
+       }
+
        public ShadowMatch matchesAdviceExecution(Method aMethod) {
-               Shadow s = ReflectionShadow.makeAdviceExecutionShadow(world, aMethod,this.matchContext);
+               Shadow s = ReflectionShadow.makeAdviceExecutionShadow(world, aMethod, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aMethod);
                sm.setWithinCode(null);
                sm.setWithinType(aMethod.getDeclaringClass());
                return sm;
        }
-       
+
        public ShadowMatch matchesInitialization(Constructor aConstructor) {
-               Shadow s = ReflectionShadow.makeInitializationShadow(world, aConstructor,this.matchContext);
+               Shadow s = ReflectionShadow.makeInitializationShadow(world, aConstructor, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aConstructor);
                sm.setWithinCode(null);
                sm.setWithinType(aConstructor.getDeclaringClass());
                return sm;
        }
-       
+
        public ShadowMatch matchesPreInitialization(Constructor aConstructor) {
-               Shadow s = ReflectionShadow.makePreInitializationShadow(world, aConstructor,this.matchContext);
+               Shadow s = ReflectionShadow.makePreInitializationShadow(world, aConstructor, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aConstructor);
                sm.setWithinCode(null);
                sm.setWithinType(aConstructor.getDeclaringClass());
                return sm;
        }
-       
+
        public ShadowMatch matchesMethodCall(Method aMethod, Member withinCode) {
-               Shadow s = ReflectionShadow.makeCallShadow(world, aMethod, withinCode,this.matchContext);
+               Shadow s = ReflectionShadow.makeCallShadow(world, aMethod, withinCode, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aMethod);
                sm.setWithinCode(withinCode);
                sm.setWithinType(withinCode.getDeclaringClass());
                return sm;
        }
-       
+
        public ShadowMatch matchesMethodCall(Method aMethod, Class callerType) {
-               Shadow s = ReflectionShadow.makeCallShadow(world, aMethod, callerType,this.matchContext);
+               Shadow s = ReflectionShadow.makeCallShadow(world, aMethod, callerType, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aMethod);
                sm.setWithinCode(null);
                sm.setWithinType(callerType);
                return sm;
        }
-       
+
        public ShadowMatch matchesConstructorCall(Constructor aConstructor, Class callerType) {
-               Shadow s = ReflectionShadow.makeCallShadow(world, aConstructor, callerType,this.matchContext);
+               Shadow s = ReflectionShadow.makeCallShadow(world, aConstructor, callerType, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aConstructor);
                sm.setWithinCode(null);
                sm.setWithinType(callerType);
                return sm;
        }
-       
+
        public ShadowMatch matchesConstructorCall(Constructor aConstructor, Member withinCode) {
-               Shadow s = ReflectionShadow.makeCallShadow(world, aConstructor,withinCode,this.matchContext);
+               Shadow s = ReflectionShadow.makeCallShadow(world, aConstructor, withinCode, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aConstructor);
                sm.setWithinCode(withinCode);
@@ -178,59 +182,59 @@ public class PointcutExpressionImpl implements PointcutExpression {
        }
 
        public ShadowMatch matchesHandler(Class exceptionType, Class handlingType) {
-               Shadow s = ReflectionShadow.makeHandlerShadow(world,exceptionType,handlingType,this.matchContext);
+               Shadow s = ReflectionShadow.makeHandlerShadow(world, exceptionType, handlingType, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(null);
                sm.setWithinCode(null);
                sm.setWithinType(handlingType);
                return sm;
        }
-       
+
        public ShadowMatch matchesHandler(Class exceptionType, Member withinCode) {
-               Shadow s = ReflectionShadow.makeHandlerShadow(world,exceptionType,withinCode,this.matchContext);
+               Shadow s = ReflectionShadow.makeHandlerShadow(world, exceptionType, withinCode, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(null);
                sm.setWithinCode(withinCode);
                sm.setWithinType(withinCode.getDeclaringClass());
                return sm;
        }
-       
+
        public ShadowMatch matchesFieldGet(Field aField, Class withinType) {
-               Shadow s = ReflectionShadow.makeFieldGetShadow(world, aField, withinType,this.matchContext);
+               Shadow s = ReflectionShadow.makeFieldGetShadow(world, aField, withinType, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aField);
                sm.setWithinCode(null);
                sm.setWithinType(withinType);
                return sm;
        }
-       
+
        public ShadowMatch matchesFieldGet(Field aField, Member withinCode) {
-               Shadow s = ReflectionShadow.makeFieldGetShadow(world, aField, withinCode,this.matchContext);
+               Shadow s = ReflectionShadow.makeFieldGetShadow(world, aField, withinCode, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aField);
                sm.setWithinCode(withinCode);
                sm.setWithinType(withinCode.getDeclaringClass());
                return sm;
        }
-       
+
        public ShadowMatch matchesFieldSet(Field aField, Class withinType) {
-               Shadow s = ReflectionShadow.makeFieldSetShadow(world, aField, withinType,this.matchContext);
+               Shadow s = ReflectionShadow.makeFieldSetShadow(world, aField, withinType, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aField);
                sm.setWithinCode(null);
                sm.setWithinType(withinType);
                return sm;
        }
-       
+
        public ShadowMatch matchesFieldSet(Field aField, Member withinCode) {
-               Shadow s = ReflectionShadow.makeFieldSetShadow(world, aField, withinCode,this.matchContext);
+               Shadow s = ReflectionShadow.makeFieldSetShadow(world, aField, withinCode, this.matchContext);
                ShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aField);
                sm.setWithinCode(withinCode);
                sm.setWithinType(withinCode.getDeclaringClass());
                return sm;
        }
-       
+
        private ShadowMatchImpl getShadowMatch(Shadow forShadow) {
                org.aspectj.util.FuzzyBoolean match = pointcut.match(forShadow);
                Test residueTest = Literal.TRUE;
@@ -238,12 +242,14 @@ public class PointcutExpressionImpl implements PointcutExpression {
                if (match.maybeTrue()) {
                        residueTest = pointcut.findResidue(forShadow, state);
                }
-               ShadowMatchImpl sm = new ShadowMatchImpl(match,residueTest,state,parameters);
+               ShadowMatchImpl sm = new ShadowMatchImpl(match, residueTest, state, parameters);
                sm.setMatchingContext(this.matchContext);
                return sm;
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.aspectj.weaver.tools.PointcutExpression#getPointcutExpression()
         */
        public String getPointcutExpression() {
@@ -252,74 +258,87 @@ public class PointcutExpressionImpl implements PointcutExpression {
 
        private static class HasPossibleDynamicContentVisitor extends AbstractPatternNodeVisitor {
                private boolean hasDynamicContent = false;
-               
-               public boolean hasDynamicContent() { return hasDynamicContent; }
-               
+
+               public boolean hasDynamicContent() {
+                       return hasDynamicContent;
+               }
+
+               @Override
                public Object visit(WithinAnnotationPointcut node, Object data) {
                        hasDynamicContent = true;
                        return null;
                }
-               
+
+               @Override
                public Object visit(WithinCodeAnnotationPointcut node, Object data) {
                        hasDynamicContent = true;
                        return null;
                }
-               
+
+               @Override
                public Object visit(AnnotationPointcut node, Object data) {
                        hasDynamicContent = true;
                        return null;
                }
-               
+
+               @Override
                public Object visit(ArgsAnnotationPointcut node, Object data) {
                        hasDynamicContent = true;
                        return null;
                }
-               
+
+               @Override
                public Object visit(ArgsPointcut node, Object data) {
                        hasDynamicContent = true;
                        return null;
                }
 
+               @Override
                public Object visit(CflowPointcut node, Object data) {
                        hasDynamicContent = true;
                        return null;
                }
-               
+
+               @Override
                public Object visit(IfPointcut node, Object data) {
                        hasDynamicContent = true;
                        return null;
                }
-               
+
+               @Override
                public Object visit(NotAnnotationTypePattern node, Object data) {
                        return node.getNegatedPattern().accept(this, data);
                }
-               
+
+               @Override
                public Object visit(NotPointcut node, Object data) {
                        return node.getNegatedPointcut().accept(this, data);
                }
-               
+
+               @Override
                public Object visit(ThisOrTargetAnnotationPointcut node, Object data) {
                        hasDynamicContent = true;
                        return null;
                }
-               
+
+               @Override
                public Object visit(ThisOrTargetPointcut node, Object data) {
                        hasDynamicContent = true;
                        return null;
                }
-               
+
        }
-       
+
        public static class Handler implements Member {
 
                private Class decClass;
                private Class exType;
-               
+
                public Handler(Class decClass, Class exType) {
                        this.decClass = decClass;
                        this.exType = exType;
                }
-               
+
                public int getModifiers() {
                        return 0;
                }