Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.Pointcut


    int[] pcLocation = new int[2];
    String pointcutExpression = getStringLiteralFor("pointcut",adviceAnn,pcLocation);
    if (pointcutExpression == null) pointcutExpression = getStringLiteralFor("value",adviceAnn,pcLocation);
    try {
      ISourceContext context = new EclipseSourceContext(unit.compilationResult,pcLocation[0]);
      Pointcut pc = new PatternParser(pointcutExpression,context).parsePointcut();
      FormalBinding[] bindings = buildFormalAdviceBindingsFrom(methodDeclaration);
      pc.resolve(new EclipseScope(bindings,methodDeclaration.scope));
      EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(methodDeclaration.scope);
      // now create a ResolvedPointcutDefinition,make an attribute out of it, and add it to the method
      UnresolvedType[] paramTypes = new UnresolvedType[bindings.length];
      for (int i = 0; i < paramTypes.length; i++) paramTypes[i] = bindings[i].getType();
      ResolvedPointcutDefinition resPcutDef =
View Full Code Here


    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) {
                ;//will have to ensure abstract ()V method
            } else {
                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
                pc.resolve(new EclipseScope(bindings,methodDeclaration.scope));
                HasIfPCDVisitor ifFinder = new HasIfPCDVisitor();
                pc.traverse(ifFinder, null);
                containsIfPcd = ifFinder.containsIfPcd;
            }
        } catch(ParserException pEx) {
      methodDeclaration.scope.problemReporter().parseError(
          pcLocation[0] + pEx.getLocation().getStart(),
View Full Code Here

    } else if (declare instanceof DeclareSoft) {
      DeclareSoft d = (DeclareSoft)declare;
      // Ordered so that during concretization we can check the related munger
      ShadowMunger m = Advice.makeSoftener(world, d.getPointcut(), d.getException(),inAspect,d);
      m.setDeclaringType(d.getDeclaringType());
      Pointcut concretePointcut = d.getPointcut().concretize(inAspect, d.getDeclaringType(), 0,m);
      m.pointcut = concretePointcut;
      declareSofts.add(new DeclareSoft(d.getException(), concretePointcut));
      addConcreteShadowMunger(m);
    } else if (declare instanceof DeclareAnnotation) {
        // FIXME asc perf Possible Improvement. Investigate why this is called twice in a weave ?
View Full Code Here

    /** @param fromType is guaranteed to be a non-abstract aspect
     *  @param clause has been concretized at a higher level
     */
    public ShadowMunger concretize(ResolvedType fromType, World world, PerClause clause) {
      // assert !fromType.isAbstract();
        Pointcut p = pointcut.concretize(fromType, getDeclaringType(), signature.getArity(), this);
        if (clause != null) {
          Pointcut oldP = p;
          p = new AndPointcut(clause, p);
          p.copyLocationFrom(oldP);
          p.state = Pointcut.CONCRETE;

            //FIXME ? ATAJ copy unbound bindings to ignore
View Full Code Here

    clearLintSuppressions(world,this.suppressedLintKinds);
    return ret;
  }
 
  public ShadowMunger parameterizeWith(ResolvedType declaringType,Map typeVariableMap) {
    Pointcut pc = getPointcut().parameterizeWith(typeVariableMap);
   
    BcelAdvice ret = null;
    Member adviceSignature = signature;   
    // allows for around advice where the return value is a type variable (see pr115250)
    if (signature instanceof ResolvedMember && signature.getDeclaringType().isGenericType()) {
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

                );

                // 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());
                struct.ajAttributes.add(
View Full Code Here

                );

                // 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());
                struct.ajAttributes.add(
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());
            struct.ajAttributes.add(
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());
            struct.ajAttributes.add(
View Full Code Here

TOP

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

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.