Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.PerClause$Kind


   */
  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);
      perClause = new PerCflow(pointcut, false);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERCFLOWBELOW.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERCFLOWBELOW.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
      perClause = new PerCflow(pointcut, true);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTARGET.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERTARGET.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
      perClause = new PerObject(pointcut, false);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTHIS.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERTHIS.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
      perClause = new PerObject(pointcut, true);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTYPEWITHIN.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERTYPEWITHIN.extractPointcut(perClauseString);
      typePattern = parseTypePattern(pointcutString, struct);
      perClause = new PerTypeWithin(typePattern);
    } else if (perClauseString.equalsIgnoreCase(PerClause.SINGLETON.getName() + "()")) {
      perClause = new PerSingleton();
    } else {
      // could not parse the @AJ perclause - fallback to singleton and
      // issue an error
      reportError("@Aspect per clause cannot be read '" + perClauseString + "'", struct);
      return null;
    }

    if (!PerClause.SINGLETON.equals(perClause.getKind()) && !PerClause.PERTYPEWITHIN.equals(perClause.getKind())
        && pointcut == null) {
      // we could not parse the pointcut
      return null;
    }
    if (PerClause.PERTYPEWITHIN.equals(perClause.getKind()) && typePattern == null) {
      // we could not parse the type pattern
      return null;
    }
    return perClause;
  }
View Full Code Here


    return this.typeVariables;
  }

  @Override
  public PerClause getPerClause() {
    PerClause pclause = getDelegate().getPerClause();
    if (pclause != null && isParameterizedType()) { // could cache the result here...
      Map<String, UnresolvedType> parameterizationMap = getAjMemberParameterizationMap();
      pclause = (PerClause) pclause.parameterizeWith(parameterizationMap, world);
    }
    return pclause;
  }
View Full Code Here

   */
  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);
      perClause = new PerCflow(pointcut, false);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERCFLOWBELOW.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERCFLOWBELOW.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
      perClause = new PerCflow(pointcut, true);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTARGET.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERTARGET.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
      perClause = new PerObject(pointcut, false);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTHIS.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERTHIS.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
      perClause = new PerObject(pointcut, true);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTYPEWITHIN.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERTYPEWITHIN.extractPointcut(perClauseString);
      typePattern = parseTypePattern(pointcutString, struct);
      perClause = new PerTypeWithin(typePattern);
    } else if (perClauseString.equalsIgnoreCase(PerClause.SINGLETON.getName() + "()")) {
      perClause = new PerSingleton();
    } else {
      // could not parse the @AJ perclause - fallback to singleton and
      // issue an error
      reportError("@Aspect per clause cannot be read '" + perClauseString + "'", struct);
      return null;
    }

    if (!PerClause.SINGLETON.equals(perClause.getKind()) && !PerClause.PERTYPEWITHIN.equals(perClause.getKind())
        && pointcut == null) {
      // we could not parse the pointcut
      return null;
    }
    if (PerClause.PERTYPEWITHIN.equals(perClause.getKind()) && typePattern == null) {
      // we could not parse the type pattern
      return null;
    }
    return perClause;
  }
View Full Code Here

    return this.typeVariables;
  }

  @Override
  public PerClause getPerClause() {
    PerClause pclause = getDelegate().getPerClause();
    if (isParameterizedType()) { // could cache the result here...
      Map parameterizationMap = getAjMemberParameterizationMap();
      pclause = (PerClause) pclause.parameterizeWith(parameterizationMap, world);
    }
    return pclause;
  }
View Full Code Here

        }
        extendsAspect = struct.enclosingType.getSuperclass().isAspect();
      }

      NameValuePair aspectPerClause = getAnnotationElement(aspect, VALUE);
      final PerClause perClause;
      if (aspectPerClause == null) {
        // empty value means singleton unless inherited
        if (!extendsAspect) {
          perClause = new PerSingleton();
        } else {
          perClause = new PerFromSuper(struct.enclosingType.getSuperclass().getPerClause().getKind());
        }
      } else {
        String perX = aspectPerClause.getValue().stringifyValue();
        if (perX == null || perX.length() <= 0) {
          perClause = new PerSingleton();
        } else {
          perClause = parsePerClausePointcut(perX, struct);
        }
      }
      if (perClause == null) {
        // could not parse it, ignore the aspect
        return false;
      } else {
        perClause.setLocation(struct.context, -1, -1);// struct.context.getOffset(),
        // struct.context.getOffset()+1);//FIXME
        // AVASM
        // FIXME asc see related comment way about about the version...
        struct.ajAttributes.add(new AjAttribute.WeaverVersionInfo());
        AjAttribute.Aspect aspectAttribute = new AjAttribute.Aspect(perClause);
View Full Code Here

    }
    return this.typeVariables;
  }
 
  public PerClause getPerClause() {
    PerClause pclause = delegate.getPerClause();
    if (isParameterizedType()) { // could cache the result here...
      Map parameterizationMap = getAjMemberParameterizationMap();
      pclause = (PerClause)pclause.parameterizeWith(parameterizationMap);
    }
    return pclause;
  }
View Full Code Here

 
 
  public PerClause parsePerClause(Parser parser) {
    PatternParser patternParser = new PatternParser(tokenSource);
    try {
      PerClause ret = patternParser.maybeParsePerClause();
      checkEof(parser);
      if (ret == null) return new PerSingleton();
      else return ret;
    } catch (ParserException pe) {
      reportError(parser, pe);
View Full Code Here

  }
 

 
  private PerClause.Kind lookupPerClauseKind(ReferenceBinding binding) {
        PerClause perClause;
        if (binding instanceof BinaryTypeBinding) {
            ResolvedType superTypeX = factory.fromEclipse(binding);
            perClause = superTypeX.getPerClause();
        } else if (binding instanceof SourceTypeBinding ) {
      SourceTypeBinding sourceSc = (SourceTypeBinding)binding;
      if (sourceSc.scope.referenceContext instanceof AspectDeclaration) {
        perClause = ((AspectDeclaration)sourceSc.scope.referenceContext).perClause;
      } else {
        return null;
      }
        } else if (binding instanceof ParameterizedTypeBinding) {
          ParameterizedTypeBinding pBinding = (ParameterizedTypeBinding)binding;
          if (pBinding.type instanceof SourceTypeBinding) {
            SourceTypeBinding sourceSc = (SourceTypeBinding)pBinding.type;
            if (sourceSc.scope != null && sourceSc.scope.referenceContext instanceof AspectDeclaration) {
          perClause = ((AspectDeclaration)sourceSc.scope.referenceContext).perClause;
        } else {
          return null;
        }
          } else {
            perClause=null;
          }
    } else {
      //XXX need to handle this too
      return null;
    }
        if (perClause == null) {
            return lookupPerClauseKind(binding.superclass());
        } else {
            return perClause.getKind();
      }
    }
View Full Code Here

    //should probably be: ((AspectDeclaration)declaration).perClause;
    // but we don't need this level of detail, and working with real per clauses
    // at this stage of compilation is not worth the trouble
        if (!isAnnotationStyleAspect()) {
             if(declaration instanceof AspectDeclaration) {
               PerClause pc = ((AspectDeclaration)declaration).perClause;
               if (pc != null) return pc;
             }
            return new PerSingleton();
        } else {
            // for @Aspect, we do need the real kind though we don't need the real perClause
            // at least try to get the right perclause
          PerClause pc = null;
          if (declaration instanceof AspectDeclaration)
           pc =  ((AspectDeclaration)declaration).perClause;
        if (pc==null) {
              PerClause.Kind kind = getPerClauseForTypeDeclaration(declaration);
              //returning a perFromSuper is enough to get the correct kind.. (that's really a hack - AV)
View Full Code Here

    // adapted from AspectDeclaration
    private PerClause.Kind lookupPerClauseKind(ReferenceBinding binding) {
        final PerClause.Kind kind;
        if (binding instanceof BinaryTypeBinding) {
            ResolvedType superTypeX = factory.fromEclipse(binding);
            PerClause perClause = superTypeX.getPerClause();
            // clause is null for non aspect classes since coming from BCEL attributes
            if (perClause != null) {
                kind = superTypeX.getPerClause().getKind();
            } else {
                kind = null;
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.patterns.PerClause$Kind

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.