Package org.aspectj.weaver.patterns

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


    private Pointcut findFirstPointcutIn(Pointcut toSearch, Class toLookFor) {
      if (toSearch instanceof NotPointcut) return null;
      if (toLookFor.isInstance(toSearch)) return toSearch;
      if (toSearch instanceof AndPointcut) {
        AndPointcut apc = (AndPointcut) toSearch;
        Pointcut left = findFirstPointcutIn(apc.getLeft(),toLookFor);
        if (left != null) return left;
        return findFirstPointcutIn(apc.getRight(),toLookFor);
      }
      return null;
    }
View Full Code Here


    throws UnsupportedPointcutPrimitiveException, IllegalArgumentException {
       PointcutExpressionImpl pcExpr = null;
         try {
           PatternParser parser = new PatternParser(expression);
           parser.setPointcutDesignatorHandlers(pointcutDesignators, world);
             Pointcut pc = parser.parsePointcut();
             validateAgainstSupportedPrimitives(pc,expression);
             IScope resolutionScope = buildResolutionScope((inScope == null ? Object.class : inScope),formalParameters);
             pc = pc.resolve(resolutionScope);
             ResolvedType declaringTypeForResolution = null;
             if (inScope != null) {
               declaringTypeForResolution = getWorld().resolve(inScope.getName());
             } else {
               declaringTypeForResolution = ResolvedType.OBJECT.resolve(getWorld());
             }
             IntMap arity = new IntMap(formalParameters.length);
             for (int i = 0; i < formalParameters.length; i++) {
               arity.put(i, i);
             }            
             pc = pc.concretize(declaringTypeForResolution, declaringTypeForResolution, arity);
             validateAgainstSupportedPrimitives(pc,expression); // again, because we have now followed any ref'd pcuts
             pcExpr = new PointcutExpressionImpl(pc,expression,formalParameters,getWorld());
         } catch (ParserException pEx) {
             throw new IllegalArgumentException(buildUserMessageFromParserException(expression,pEx));
         } catch (ReflectionWorld.ReflectionWorldException rwEx) {
View Full Code Here

    super();
    sourceStart = tokens.sourceStart;
    sourceEnd = tokens.sourceEnd;
    this.tokens = tokens;
   
    Pointcut pc = tokens.parsePointcut(parser);
    if (pc.toString().equals("")) { //??? is this a good signal
      isError = true;
    }
    pointcut = pc;
  }
View Full Code Here

  }
 
  public Pointcut parsePointcut(Parser parser) {
    PatternParser patternParser = new PatternParser(tokenSource);
    try {
      Pointcut ret = patternParser.parsePointcut();
      checkEof(parser);
      return ret;
    } catch (ParserException pe) {
      reportError(parser, pe);
      return Pointcut.makeMatchesNothing(Pointcut.SYMBOLIC);
View Full Code Here

    AspectDeclaration aspectDecl = new AspectDeclaration(typeDecl.compilationResult);

    try {
      if (perClause != null && !perClause.equals("")) {
        ISourceContext context = new EclipseSourceContext(unit.compilationResult,pcLoc[0]);
        Pointcut pc = new PatternParser(perClause,context).maybeParsePerClause();
          FormalBinding[] bindings = new FormalBinding[0];
        if (pc != null) pc.resolve(new EclipseScope(bindings,typeDecl.scope));
      }
    } catch(ParserException pEx) {
      typeDecl.scope.problemReporter().parseError(
          pcLoc[0] + pEx.getLocation().getStart(),
          pcLoc[0] + pEx.getLocation().getEnd() ,
View Full Code Here

    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

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.