Example #1
0
 public AndPointcut(Pointcut left, Pointcut right) {
   super();
   this.left = left;
   this.right = right;
   this.pointcutKind = AND;
   setLocation(left.getSourceContext(), left.getStart(), right.getEnd());
   couldMatchKinds = left.couldMatchKinds() & right.couldMatchKinds();
 }
 // a higher score means a more expensive evaluation
 private int getScore(Pointcut p) {
   if (p.couldMatchKinds() == Shadow.NO_SHADOW_KINDS_BITS) {
     return MATCHES_NOTHING;
   }
   if (p instanceof WithinPointcut) {
     return WITHIN;
   }
   if (p instanceof WithinAnnotationPointcut) {
     return ATWITHIN;
   }
   if (p instanceof KindedPointcut) {
     KindedPointcut kp = (KindedPointcut) p;
     Shadow.Kind kind = kp.getKind();
     if (kind == Shadow.AdviceExecution) {
       return ADVICEEXECUTION;
     } else if ((kind == Shadow.ConstructorCall) || (kind == Shadow.MethodCall)) {
       TypePattern declaringTypePattern = kp.getSignature().getDeclaringType();
       if (declaringTypePattern instanceof AnyTypePattern) {
         return CALL_WITHOUT_DECLARING_TYPE;
       } else {
         return CALL_WITH_DECLARING_TYPE;
       }
     } else if ((kind == Shadow.ConstructorExecution)
         || (kind == Shadow.MethodExecution)
         || (kind == Shadow.Initialization)
         || (kind == Shadow.PreInitialization)) {
       return EXE_INIT_PREINIT;
     } else if (kind == Shadow.ExceptionHandler) {
       return HANDLER;
     } else if ((kind == Shadow.FieldGet) || (kind == Shadow.FieldSet)) {
       return GET_OR_SET;
     } else if (kind == Shadow.StaticInitialization) {
       return STATICINIT;
     } else {
       return OTHER;
     }
   }
   if (p instanceof AnnotationPointcut) {
     return ANNOTATION;
   }
   if (p instanceof ArgsPointcut) {
     return ARGS;
   }
   if (p instanceof ArgsAnnotationPointcut) {
     return AT_ARGS;
   }
   if (p instanceof CflowPointcut || p instanceof ConcreteCflowPointcut) {
     return CFLOW;
   }
   if (p instanceof HandlerPointcut) {
     return HANDLER;
   }
   if (p instanceof IfPointcut) {
     return IF;
   }
   if (p instanceof ThisOrTargetPointcut) {
     return THIS_OR_TARGET;
   }
   if (p instanceof ThisOrTargetAnnotationPointcut) {
     return AT_THIS_OR_TARGET;
   }
   if (p instanceof WithincodePointcut) {
     return WITHINCODE;
   }
   if (p instanceof WithinCodeAnnotationPointcut) {
     return ATWITHINCODE;
   }
   if (p instanceof NotPointcut) {
     return getScore(((NotPointcut) p).getNegatedPointcut());
   }
   if (p instanceof AndPointcut) {
     int leftScore = getScore(((AndPointcut) p).getLeft());
     int rightScore = getScore(((AndPointcut) p).getRight());
     if (leftScore < rightScore) {
       return leftScore;
     } else {
       return rightScore;
     }
   }
   if (p instanceof OrPointcut) {
     int leftScore = getScore(((OrPointcut) p).getLeft());
     int rightScore = getScore(((OrPointcut) p).getRight());
     if (leftScore > rightScore) {
       return leftScore;
     } else {
       return rightScore;
     }
   }
   return OTHER;
 }