Package org.aspectj.weaver

Examples of org.aspectj.weaver.ResolvedPointcutDefinition


        ((ResolvedPointcutDefinition) pointcuts[i]).setParameterNames(pnames);
        ((ResolvedPointcutDefinition) pointcuts[i]).setPointcut(pc);
      }
      // phase 3, now concretize them all
      for (int i = 0; i < pointcuts.length; i++) {
        ResolvedPointcutDefinition rpd = (ResolvedPointcutDefinition) pointcuts[i];
        rpd.setPointcut(parser.concretizePointcutExpression(rpd.getPointcut(), getBaseClass(), parameters[i]));
      }
    }
    return pointcuts;
  }
View Full Code Here


  private static void addPointcuts(AsmManager model, String sourcefilename, ResolvedType aspect,
      IProgramElement containingAspect, ResolvedMember[] pointcuts) {
    for (int i = 0; i < pointcuts.length; i++) {
      ResolvedMember pointcut = pointcuts[i];
      if (pointcut instanceof ResolvedPointcutDefinition) {
        ResolvedPointcutDefinition rpcd = (ResolvedPointcutDefinition) pointcut;
        Pointcut p = rpcd.getPointcut();
        ISourceLocation sLoc = (p == null ? null : p.getSourceLocation());
        if (sLoc == null) {
          sLoc = rpcd.getSourceLocation();
        }
        ISourceLocation pointcutLocation = (sLoc == null ? null : createSourceLocation(sourcefilename, aspect, sLoc));
        ProgramElement pointcutElement = new ProgramElement(model, pointcut.getName(), IProgramElement.Kind.POINTCUT,
            pointcutLocation, pointcut.getModifiers(), NO_COMMENT, Collections.EMPTY_LIST);
        containingAspect.addChild(pointcutElement);
View Full Code Here

  private static void addChildNodes(AsmManager asm, ResolvedType aspect, IProgramElement parent, ResolvedMember[] children) {
    for (int i = 0; i < children.length; i++) {
      ResolvedMember pcd = children[i];
      if (pcd instanceof ResolvedPointcutDefinition) {
        ResolvedPointcutDefinition rpcd = (ResolvedPointcutDefinition) pcd;
        Pointcut p = rpcd.getPointcut();
        ISourceLocation sLoc = (p == null ? null : p.getSourceLocation());
        if (sLoc == null) {
          sLoc = rpcd.getSourceLocation();
        }
        parent.addChild(new ProgramElement(asm, pcd.getName(), IProgramElement.Kind.POINTCUT, getBinarySourceLocation(
            aspect, sLoc), pcd.getModifiers(), null, Collections.EMPTY_LIST));
      }
    }
View Full Code Here

        if (amd == null || amd.ignoreFurtherInvestigation) {
          continue;
        }
        if (amd instanceof PointcutDeclaration) {
          PointcutDeclaration d = (PointcutDeclaration) amd;
          ResolvedPointcutDefinition df = d.makeResolvedPointcutDefinition(factory);
          if (df != null) {
            declaredPointcuts.add(df);
          }
        } else if (amd instanceof InterTypeDeclaration) {
          // these are handled in a separate pass
          continue;
        } else if (amd instanceof DeclareDeclaration && !(amd instanceof DeclareAnnotationDeclaration)) { // surfaces
          // the
          // annotated
          // ajc$ method
          // these are handled in a separate pass
          continue;
        } else if (amd instanceof AdviceDeclaration) {
          // these are ignored during compilation and only used during
          // weaving
          continue;
        } else if ((amd.annotations != null) && isAnnotationStylePointcut(amd.annotations)) {
          // consider pointcuts defined via annotations
          ResolvedPointcutDefinition df = makeResolvedPointcutDefinition(amd);
          if (df != null) {
            declaredPointcuts.add(df);
          }
        } else {
          if (amd.binding == null || !amd.binding.isValidBinding()) {
View Full Code Here

      }
    }

    FormalBinding[] bindings = buildFormalAdviceBindingsFrom(md);

    ResolvedPointcutDefinition rpd = new LazyResolvedPointcutDefinition(factory.fromBinding(md.binding.declaringClass),
        md.modifiers, new String(md.selector), factory.fromBindings(md.binding.parameters), factory
            .fromBinding(md.binding.returnType), pc, new EclipseScope(bindings, md.scope));

    rpd.setPosition(md.sourceStart, md.sourceEnd);
    rpd.setSourceContext(eSourceContext);
    return rpd;
  }
View Full Code Here

    }

    final IfPointcut ret;
    if (extraParameterFlags < 0 && testMethod == null) {
      // @AJ style, we need to find the testMethod in the aspect defining the "if()" enclosing pointcut
      ResolvedPointcutDefinition def = bindings.peekEnclosingDefinition();
      if (def != null) {
        ResolvedType aspect = inAspect.getWorld().resolve(def.getDeclaringType());
        for (Iterator memberIter = aspect.getMethods(true, true); memberIter.hasNext();) {
          ResolvedMember method = (ResolvedMember) memberIter.next();
          if (def.getName().equals(method.getName())
              && def.getParameterTypes().length == method.getParameterTypes().length) {
            boolean sameSig = true;
            for (int j = 0; j < method.getParameterTypes().length; j++) {
              UnresolvedType argJ = method.getParameterTypes()[j];
              if (!argJ.equals(def.getParameterTypes()[j])) {
                sameSig = false;
                break;
              }
            }
            if (sameSig) {
              testMethod = method;
              break;
            }
          }
        }
        if (testMethod == null) {
          inAspect.getWorld().showMessage(IMessage.ERROR,
              "Cannot find if() body from '" + def.toString() + "' for '" + enclosingPointcutHint + "'",
              this.getSourceLocation(), null);
          return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
        }
      } else {
        testMethod = inAspect.getWorld().resolve(bindings.getAdviceSignature());
      }
      ret = new IfPointcut(enclosingPointcutHint);
      ret.testMethod = testMethod;
    } else {
      ret = new IfPointcut(testMethod, extraParameterFlags);
    }
    ret.copyLocationFrom(this);
    partiallyConcretized = ret;

    // It is possible to directly code your pointcut expression in a per clause
    // rather than defining a pointcut declaration and referencing it in your
    // per clause. If you do this, we have problems (bug #62458). For now,
    // let's police that you are trying to code a pointcut in a per clause and
    // put out a compiler error.
    if (bindings.directlyInAdvice() && bindings.getEnclosingAdvice() == null) {
      // Assumption: if() is in a per clause if we say we are directly in advice
      // but we have no enclosing advice.
      inAspect.getWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.IF_IN_PERCLAUSE),
          this.getSourceLocation(), null);
      return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
    }

    if (bindings.directlyInAdvice()) {
      ShadowMunger advice = bindings.getEnclosingAdvice();
      if (advice instanceof Advice) {
        ret.baseArgsCount = ((Advice) advice).getBaseParameterCount();
      } else {
        ret.baseArgsCount = 0;
      }
      ret.residueSource = advice.getPointcut().concretize(inAspect, inAspect, ret.baseArgsCount, advice);
    } else {
      ResolvedPointcutDefinition def = bindings.peekEnclosingDefinition();
      if (def == CflowPointcut.CFLOW_MARKER) {
        inAspect.getWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.IF_LEXICALLY_IN_CFLOW),
            getSourceLocation(), null);
        return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
      }
      ret.baseArgsCount = def.getParameterTypes().length;

      // for @style, we have implicit binding for JoinPoint.* things
      // FIXME AV - will lead to failure for "args(jp)" test(jp, thejp) / see args() implementation
      if (ret.extraParameterFlags < 0) {
        ret.baseArgsCount = 0;
        for (int i = 0; i < testMethod.getParameterTypes().length; i++) {
          String argSignature = testMethod.getParameterTypes()[i].getSignature();
          if (AjcMemberMaker.TYPEX_JOINPOINT.getSignature().equals(argSignature)
              || AjcMemberMaker.TYPEX_PROCEEDINGJOINPOINT.getSignature().equals(argSignature)
              || AjcMemberMaker.TYPEX_STATICJOINPOINT.getSignature().equals(argSignature)
              || AjcMemberMaker.TYPEX_ENCLOSINGSTATICJOINPOINT.getSignature().equals(argSignature)) {

          } else {
            ret.baseArgsCount++;
          }
        }
      }

      IntMap newBindings = IntMap.idMap(ret.baseArgsCount);
      newBindings.copyContext(bindings);
      ret.residueSource = def.getPointcut().concretize(inAspect, declaringType, newBindings);
    }

    return ret;
  }
View Full Code Here

  public Object visit(ReferencePointcut node, Object data) {
    // && pc_ref()
    // we know there is no support for binding in perClause: perthis(pc_ref(java.lang.String))
    // TODO AV - may need some work for generics..

    ResolvedPointcutDefinition pointcutDec;
    ResolvedType searchStart = m_fromAspectType;
    if (node.onType != null) {
      searchStart = node.onType.resolve(m_fromAspectType.getWorld());
      if (searchStart.isMissing()) {
        return MAYBE;// this should not happen since concretize will fails but just in case..
      }
    }
    pointcutDec = searchStart.findPointcut(node.name);

    return getPerTypePointcut(pointcutDec.getPointcut());
  }
View Full Code Here

    // System.out.println("pc: " + getPointcut() + ", " + getPointcut().state);
    ReferenceBinding declaringClass = binding.declaringClass;
    TypeBinding[] parameters = binding.parameters;
    UnresolvedType utDeclaringClass = inWorld.fromBinding(declaringClass);
    UnresolvedType[] utParameters = inWorld.fromBindings(parameters);
    resolvedPointcutDeclaration = new ResolvedPointcutDefinition(utDeclaringClass, declaredModifiers, declaredName,
        utParameters, getPointcut()); // ??? might want to
    // use null

    resolvedPointcutDeclaration.setPosition(sourceStart, sourceEnd);
    resolvedPointcutDeclaration.setSourceContext(new EclipseSourceContext(compilationResult));
View Full Code Here

      // 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 = new ResolvedPointcutDefinition(factory.fromBinding(((TypeDeclaration) typeStack
          .peek()).binding), methodDeclaration.modifiers, "anonymous", paramTypes, pc);
      AjAttribute attr = new AjAttribute.PointcutDeclarationAttribute(resPcutDef);
      ((AjMethodDeclaration) methodDeclaration).addAttribute(new EclipseAttributeAdapter(attr));
    } catch (ParserException pEx) {
      methodDeclaration.scope.problemReporter().parseError(pcLocation[0] + pEx.getLocation().getStart(),
View Full Code Here

        // for free variable 0 we want to ask the pointcut for the type
        // of its first argument, if we only
        // ask the advice for the type of its first argument then we'll
        // get the wrong type (pr86903)

        ResolvedPointcutDefinition enclosingDef = bindings.peekEnclosingDefinition();
        ResolvedType formalType = null;

        // Is there a useful enclosing pointcut?
        if (enclosingDef != null && enclosingDef.getParameterTypes().length > 0) {
          formalType = enclosingDef.getParameterTypes()[freeVar].resolve(world);
        } else {
          formalType = bindings.getAdviceSignature().getParameterTypes()[formalIndex].resolve(world);
        }

        ConcreteCflowPointcut.Slot slot = new ConcreteCflowPointcut.Slot(formalIndex, formalType, i);
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.ResolvedPointcutDefinition

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.