Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.Pointcut$State


        IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings);

        // joinpoint, staticJoinpoint binding
        int extraArgument = extractExtraArgument(struct.method);

        Pointcut pc = null;
        if (preResolvedPointcut != null) {
          pc = preResolvedPointcut.getPointcut();
          // pc.resolve(binding);
        } else {
          pc = parsePointcut(beforeAdvice.getValue().stringifyValue(), struct, false);
          if (pc == null) {
            return false;// parse error
          }
          pc = pc.resolve(binding);
        }
        setIgnoreUnboundBindingNames(pc, bindings);

        ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
            struct.bMethod.getDeclarationOffset());
View Full Code Here


        IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings);

        // joinpoint, staticJoinpoint binding
        int extraArgument = extractExtraArgument(struct.method);

        Pointcut pc = null;
        if (preResolvedPointcut != null) {
          pc = preResolvedPointcut.getPointcut();
        } else {
          pc = parsePointcut(afterAdvice.getValue().stringifyValue(), struct, false);
          if (pc == null) {
            return false;// parse error
          }
          pc.resolve(binding);
        }
        setIgnoreUnboundBindingNames(pc, bindings);

        ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
            struct.bMethod.getDeclarationOffset());
View Full Code Here

      // return binding
      if (returned != null) {
        extraArgument |= Advice.ExtraArgument;
      }

      Pointcut pc = null;
      if (preResolvedPointcut != null) {
        pc = preResolvedPointcut.getPointcut();
      } else {
        pc = parsePointcut(pointcut, struct, false);
        if (pc == null) {
          return false;// parse error
        }
        pc.resolve(binding);
      }
      setIgnoreUnboundBindingNames(pc, bindings);

      ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
          struct.bMethod.getDeclarationOffset());
View Full Code Here

      // return binding
      if (thrownFormal != null) {
        extraArgument |= Advice.ExtraArgument;
      }

      Pointcut pc = null;
      if (preResolvedPointcut != null) {
        pc = preResolvedPointcut.getPointcut();
      } else {
        pc = parsePointcut(pointcut, struct, false);
        if (pc == null) {
          return false;// parse error
        }
        pc.resolve(binding);
      }
      setIgnoreUnboundBindingNames(pc, bindings);

      ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
          struct.bMethod.getDeclarationOffset());
View Full Code Here

        IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings);

        // joinpoint, staticJoinpoint binding
        int extraArgument = extractExtraArgument(struct.method);

        Pointcut pc = null;
        if (preResolvedPointcut != null) {
          pc = preResolvedPointcut.getPointcut();
        } else {
          pc = parsePointcut(aroundAdvice.getValue().stringifyValue(), struct, false);
          if (pc == null) {
            return false;// parse error
          }
          pc.resolve(binding);
        }
        setIgnoreUnboundBindingNames(pc, bindings);

        ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
            struct.bMethod.getDeclarationOffset());
View Full Code Here

    UnresolvedType[] argumentTypes = new UnresolvedType[struct.method.getArgumentTypes().length];
    for (int i = 0; i < argumentTypes.length; i++) {
      argumentTypes[i] = UnresolvedType.forSignature(struct.method.getArgumentTypes()[i].getSignature());
    }

    Pointcut pc = null;
    if (struct.method.isAbstract()) {
      if ((pointcutExpr != null && isNullOrEmpty(pointcutExpr.getValue().stringifyValue())) || pointcutExpr == null) {
        // abstract pointcut
        // leave pc = null
      } else {
        reportError("Found defined @Pointcut on an abstract method", struct);
        return false;// stop
      }
    } else {
      if (pointcutExpr == null || isNullOrEmpty(pointcutExpr.getValue().stringifyValue())) {
        // the matches nothing pointcut (125475/125480) - perhaps not as
        // cleanly supported as it could be.
      } else {
        // if (pointcutExpr != null) {
        // use a LazyResolvedPointcutDefinition so that the pointcut is
        // resolved lazily
        // since for it to be resolved, we will need other pointcuts to
        // be registered as well
        pc = parsePointcut(pointcutExpr.getValue().stringifyValue(), struct, true);
        if (pc == null) {
          return false;// parse error
        }
        pc.setLocation(struct.context, -1, -1);// FIXME AVASM !! bMethod
        // is null here..
        // } else {
        // reportError("Found undefined @Pointcut on a non-abstract method",
        // struct);
        // return false;
View Full Code Here

      if (declareError != null) {
        if (!STRING_DESC.equals(struct.field.getSignature()) || struct.field.getConstantValue() == null) {
          reportError("@DeclareError used on a non String constant field", struct);
          return false;
        }
        Pointcut pc = parsePointcut(declareError.getValue().stringifyValue(), struct, false);
        if (pc == null) {
          hasError = false;// cannot parse pointcut
        } else {
          DeclareErrorOrWarning deow = new DeclareErrorOrWarning(true, pc, struct.field.getConstantValue().toString());
          setDeclareErrorOrWarningLocation(model, deow, struct);
          struct.ajAttributes.add(new AjAttribute.DeclareAttribute(deow));
          hasError = true;
        }
      }
    }
    AnnotationGen warning = getAnnotation(runtimeAnnotations, AjcMemberMaker.DECLAREWARNING_ANNOTATION);
    boolean hasWarning = false;
    if (warning != null) {
      NameValuePair declareWarning = getAnnotationElement(warning, VALUE);
      if (declareWarning != null) {
        if (!STRING_DESC.equals(struct.field.getSignature()) || struct.field.getConstantValue() == null) {
          reportError("@DeclareWarning used on a non String constant field", struct);
          return false;
        }
        Pointcut pc = parsePointcut(declareWarning.getValue().stringifyValue(), struct, false);
        if (pc == null) {
          hasWarning = false;// cannot parse pointcut
        } else {
          DeclareErrorOrWarning deow = new DeclareErrorOrWarning(false, pc, struct.field.getConstantValue().toString());
          setDeclareErrorOrWarningLocation(model, deow, struct);
View Full Code Here

   * @return pointcut, unresolved
   */
  private static Pointcut parsePointcut(String pointcutString, AjAttributeStruct struct, boolean allowIf) {
    try {
      PatternParser parser = new PatternParser(pointcutString, struct.context);
      Pointcut pointcut = parser.parsePointcut();
      parser.checkEof();
      pointcut.check(null, struct.enclosingType.getWorld());
      if (!allowIf && pointcutString.indexOf("if()") >= 0 && hasIf(pointcut)) {
        reportError("if() pointcut is not allowed at this pointcut location '" + pointcutString + "'", struct);
        return null;
      }
      pointcut.setLocation(struct.context, -1, -1);// FIXME -1,-1 is not
      // good enough
      return pointcut;
    } catch (ParserException e) {
      reportError("Invalid pointcut '" + pointcutString + "': " + e.toString()
          + (e.getLocation() == null ? "" : " at position " + e.getLocation().getStart()), struct);
View Full Code Here

   * even when one single pointcut has one common element (which can be a side-effect of DNF rewriting).
   */
  private void rewritePointcuts(List<ShadowMunger> shadowMungers) {
    PointcutRewriter rewriter = new PointcutRewriter();
    for (ShadowMunger munger : shadowMungers) {
      Pointcut p = munger.getPointcut();
      Pointcut newP = rewriter.rewrite(p);
      // validateBindings now whilst we still have around the pointcut
      // that resembles what the user actually wrote in their program
      // text.
      if (munger instanceof Advice) {
        Advice advice = (Advice) munger;
        if (advice.getSignature() != null) {
          final int numFormals;
          final String names[];
          // If the advice is being concretized in a @AJ aspect *and*
          // the advice was declared in
          // an @AJ aspect (it could have been inherited from a code
          // style aspect) then
          // evaluate the alternative set of formals. pr125699
          if ((advice.getConcreteAspect().isAnnotationStyleAspect() && advice.getDeclaringAspect() != null && advice
              .getDeclaringAspect().resolve(world).isAnnotationStyleAspect())
              || advice.isAnnotationStyle()) {
            numFormals = advice.getBaseParameterCount();
            int numArgs = advice.getSignature().getParameterTypes().length;
            if (numFormals > 0) {
              names = advice.getSignature().getParameterNames(world);
              validateBindings(newP, p, numArgs, names);
            }
          } else {
            numFormals = advice.getBaseParameterCount();
            if (numFormals > 0) {
              names = advice.getBaseParameterNames(world);
              validateBindings(newP, p, numFormals, names);
            }
          }
        }
      }
      newP.m_ignoreUnboundBindingForNames = p.m_ignoreUnboundBindingForNames;
      munger.setPointcut(newP);
    }
    // now that we have optimized individual pointcuts, optimize
    // across the set of pointcuts....
    // Use a map from key based on pc equality, to value based on
    // pc identity.
    Map/* <Pointcut,Pointcut> */<Pointcut, Pointcut> pcMap = new HashMap<Pointcut, Pointcut>();
    for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
      ShadowMunger munger = (ShadowMunger) iter.next();
      Pointcut p = munger.getPointcut();
      Pointcut newP = shareEntriesFromMap(p, pcMap);
      newP.m_ignoreUnboundBindingForNames = p.m_ignoreUnboundBindingForNames;
      munger.setPointcut(newP);
    }
  }
View Full Code Here

    if (p instanceof ConcreteCflowPointcut) {
      return p;
    }
    if (p instanceof AndPointcut) {
      AndPointcut apc = (AndPointcut) p;
      Pointcut left = shareEntriesFromMap(apc.getLeft(), pcMap);
      Pointcut right = shareEntriesFromMap(apc.getRight(), pcMap);
      return new AndPointcut(left, right);
    } else if (p instanceof OrPointcut) {
      OrPointcut opc = (OrPointcut) p;
      Pointcut left = shareEntriesFromMap(opc.getLeft(), pcMap);
      Pointcut right = shareEntriesFromMap(opc.getRight(), pcMap);
      return new OrPointcut(left, right);
    } else if (p instanceof NotPointcut) {
      NotPointcut npc = (NotPointcut) p;
      Pointcut not = shareEntriesFromMap(npc.getNegatedPointcut(), pcMap);
      return new NotPointcut(not);
    } else {
      // primitive pcd
      if (pcMap.containsKey(p)) { // based on equality
        return pcMap.get(p); // same instance (identity)
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.patterns.Pointcut$State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.