Package org.aspectj.weaver.patterns

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


    boolean containsIfPcd = false;
    int[] pcLocation = new int[2];
    String pointcutExpression = getStringLiteralFor("value", ajAnnotations.pointcutAnnotation, pcLocation);
    try {
      ISourceContext context = new EclipseSourceContext(unit.compilationResult, pcLocation[0]);
      Pointcut pc = null;// abstract
      if (pointcutExpression == null || pointcutExpression.length() == 0) {
        noValueSupplied = true; // matches nothing pointcut
      } else {
        noValueSupplied = false;
        pc = new PatternParser(pointcutExpression, context).parsePointcut();
      }
      pcDecl.pointcutDesignator = (pc == null) ? null : new PointcutDesignator(pc);
      pcDecl.setGenerateSyntheticPointcutMethod();
      TypeDeclaration onType = (TypeDeclaration) typeStack.peek();
      pcDecl.postParse(onType);
      // EclipseFactory factory =
      // EclipseFactory.fromScopeLookupEnvironment
      // (methodDeclaration.scope);
      // int argsLength = methodDeclaration.arguments == null ? 0 :
      // methodDeclaration.arguments.length;
      FormalBinding[] bindings = buildFormalAdviceBindingsFrom(methodDeclaration);
      // FormalBinding[] bindings = new FormalBinding[argsLength];
      // for (int i = 0, len = bindings.length; i < len; i++) {
      // Argument arg = methodDeclaration.arguments[i];
      // String name = new String(arg.name);
      // UnresolvedType type =
      // factory.fromBinding(methodDeclaration.binding.parameters[i]);
      // bindings[i] = new FormalBinding(type, name, i, arg.sourceStart,
      // arg.sourceEnd, "unknown");
      // }
      swap(onType, methodDeclaration, pcDecl);
      if (pc != null) {
        // has an expression
        EclipseScope eScope = new EclipseScope(bindings, methodDeclaration.scope);
        char[] packageName = null;
        if (typeDecl.binding != null && typeDecl.binding.getPackage() != null) {
          packageName = typeDecl.binding.getPackage().readableName();
        }
        eScope.setLimitedImports(packageName);
        pc.resolve(eScope);
        HasIfPCDVisitor ifFinder = new HasIfPCDVisitor();
        pc.traverse(ifFinder, null);
        containsIfPcd = ifFinder.containsIfPcd;
      }
    } catch (ParserException pEx) {
      methodDeclaration.scope.problemReporter().parseError(pcLocation[0] + pEx.getLocation().getStart(),
          pcLocation[0] + pEx.getLocation().getEnd(), -1, pointcutExpression.toCharArray(), pointcutExpression,
View Full Code Here


        for (Iterator it = attributes.iterator(); it.hasNext();) {
            AjAttribute attr = (AjAttribute) it.next();
            if (attr instanceof AjAttribute.PointcutDeclarationAttribute) {
                AjAttribute.PointcutDeclarationAttribute pcAttr = (AjAttribute.PointcutDeclarationAttribute) attr;
                Pointcut pointcut = pcAttr.reify().getPointcut();
                if (pointcut instanceof KindedPointcut) {
                    try {
                        Field sigField = KindedPointcut.class.getDeclaredField("signature");
                        sigField.setAccessible(true);
                        SignaturePattern signature = (SignaturePattern) sigField.get(pointcut);
                        DefinitionParserHelper.createAndAddPointcutDefToAspectDef(
                                signature.getName().toString(), pointcut.toString(), aspectDef
                        );
                    } catch (Exception e) {
                        throw new WrappedRuntimeException(e);
                    }
                }
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

   * @param struct for which we are parsing the per clause
   * @return a PerClause instance
   */
  private static PerClause parsePerClausePointcut(String perClauseString, AjAttributeStruct struct) {
    final String pointcutString;
    Pointcut pointcut = null;
    TypePattern typePattern = null;
    final PerClause perClause;
    if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERCFLOW.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERCFLOW.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
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();
          // 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

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.