Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.TypePattern$MatchKind


    // needs further analysis
    ResolvedType classInfo = weaver.getWorld().resolve(UnresolvedType.forName(aspectClassName), true);
    // exclude are "AND"ed
    for (Iterator iterator = m_aspectExcludeTypePattern.iterator(); iterator.hasNext();) {
      TypePattern typePattern = (TypePattern) iterator.next();
      if (typePattern.matchesStatically(classInfo)) {
        // exclude match - skip
        return false;
      }
    }
    // include are "OR"ed
    boolean accept = true;// defaults to true if no include
    for (Iterator iterator = m_aspectIncludeTypePattern.iterator(); iterator.hasNext();) {
      TypePattern typePattern = (TypePattern) iterator.next();
      accept = typePattern.matchesStatically(classInfo);
      if (accept) {
        break;
      }
      // goes on if this include did not match ("OR"ed)
    }
View Full Code Here


    // TODO AV - optimize for className.startWith only
    ResolvedType classInfo = weaver.getWorld().resolve(UnresolvedType.forName(className), true);
    // dump
    for (Iterator iterator = m_dumpTypePattern.iterator(); iterator.hasNext();) {
      TypePattern typePattern = (TypePattern) iterator.next();
      if (typePattern.matchesStatically(classInfo)) {
        // dump match
        return true;
      }
    }
    return false;
View Full Code Here

   * @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);
      perClause = new PerCflow(pointcut, false);
View Full Code Here

    AnnotationGen decp = getAnnotation(runtimeAnnotations, AjcMemberMaker.DECLAREPARENTS_ANNOTATION);
    if (decp != null) {
      NameValuePair decpPatternNVP = getAnnotationElement(decp, VALUE);
      String decpPattern = decpPatternNVP.getValue().stringifyValue();
      if (decpPattern != null) {
        TypePattern typePattern = parseTypePattern(decpPattern, struct);
        ResolvedType fieldType = UnresolvedType.forSignature(struct.field.getSignature()).resolve(
            struct.enclosingType.getWorld());
        if (fieldType.isInterface()) {
          TypePattern parent = parseTypePattern(fieldType.getName(), struct);
          FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
          IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings);
          // first add the declare implements like
          List<TypePattern> parents = new ArrayList<TypePattern>(1);
          parents.add(parent);
View Full Code Here

    World world = struct.enclosingType.getWorld();
    NameValuePair declareMixinPatternNameValuePair = getAnnotationElement(declareMixinAnnotation, VALUE);

    // declareMixinPattern could be of the form "Bar*" or "A || B" or "Foo+"
    String declareMixinPattern = declareMixinPatternNameValuePair.getValue().stringifyValue();
    TypePattern targetTypePattern = parseTypePattern(declareMixinPattern, struct);

    // Return value of the annotated method is the interface or class that the mixin delegate should have
    ResolvedType methodReturnType = UnresolvedType.forSignature(annotatedMethod.getReturnType().getSignature()).resolve(world);

    if (methodReturnType.isPrimitiveType()) {
      reportError(getMethodForMessage(struct) + ":  factory methods for a mixin cannot return void or a primitive type",
          struct);
      return false;
    }

    if (annotatedMethod.getArgumentTypes().length > 1) {
      reportError(getMethodForMessage(struct) + ": factory methods for a mixin can take a maximum of one parameter", struct);
      return false;
    }

    // The set of interfaces to be mixed in is either:
    // supplied as a list in the 'Class[] interfaces' value in the annotation value
    // supplied as just the interface return value of the annotated method
    // supplied as just the class return value of the annotated method
    NameValuePair interfaceListSpecified = getAnnotationElement(declareMixinAnnotation, "interfaces");

    List<TypePattern> newParents = new ArrayList<TypePattern>(1);
    List<ResolvedType> newInterfaceTypes = new ArrayList<ResolvedType>(1);
    if (interfaceListSpecified != null) {
      ArrayElementValue arrayOfInterfaceTypes = (ArrayElementValue) interfaceListSpecified.getValue();
      int numberOfTypes = arrayOfInterfaceTypes.getElementValuesArraySize();
      ElementValue[] theTypes = arrayOfInterfaceTypes.getElementValuesArray();
      for (int i = 0; i < numberOfTypes; i++) {
        ClassElementValue interfaceType = (ClassElementValue) theTypes[i];
        // Check: needs to be resolvable
        // TODO crappy replace required
        ResolvedType ajInterfaceType = UnresolvedType.forSignature(interfaceType.getClassString().replace("/", "."))
            .resolve(world);
        if (ajInterfaceType.isMissing() || !ajInterfaceType.isInterface()) {
          reportError(
              "Types listed in the 'interfaces' DeclareMixin annotation value must be valid interfaces. This is invalid: "
                  + ajInterfaceType.getName(), struct); // TODO better error location, use the method position
          return false;
        }
        if (!ajInterfaceType.isAssignableFrom(methodReturnType)) {
          reportError(getMethodForMessage(struct) + ": factory method does not return something that implements '"
              + ajInterfaceType.getName() + "'", struct);
          return false;
        }
        newInterfaceTypes.add(ajInterfaceType);
        // Checking that it is a superinterface of the methods return value is done at weave time
        TypePattern newParent = parseTypePattern(ajInterfaceType.getName(), struct);
        newParents.add(newParent);
      }
    } else {
      if (methodReturnType.isClass()) {
        reportError(
            getMethodForMessage(struct)
                + ": factory methods for a mixin must either return an interface type or specify interfaces in the annotation and return a class",
            struct);
        return false;
      }
      // Use the method return type: this might be a class or an interface
      TypePattern newParent = parseTypePattern(methodReturnType.getName(), struct);
      newInterfaceTypes.add(methodReturnType);
      newParents.add(newParent);
    }
    if (newParents.size() == 0) {
      // Warning: did they foolishly put @DeclareMixin(value="Bar+",interfaces={})
View Full Code Here

   * @param location
   * @return type pattern
   */
  private static TypePattern parseTypePattern(String patternString, AjAttributeStruct location) {
    try {
      TypePattern typePattern = new PatternParser(patternString).parseTypePattern();
      typePattern.setLocation(location.context, -1, -1);// FIXME -1,-1 is
      // not good
      // enough
      return typePattern;
    } catch (ParserException e) {
      reportError("Invalid type pattern'" + patternString + "' : " + e.getLocation(), location);
View Full Code Here

          Object dec = iter.next();
          if (dec instanceof DeclareParents) {
            DeclareParents decp = (DeclareParents) dec;
            TypePattern[] newparents = decp.getParents().getTypePatterns();
            for (int i = 0; i < newparents.length; i++) {
              TypePattern pattern = newparents[i];
              UnresolvedType ut = pattern.getExactType();
              if (ut == null)
                continue;
              if (CharOperation.compareWith(typeDecl.binding.signature(), ut.getSignature().toCharArray()) == 0)
                return;
            }
View Full Code Here

  public AspectJTypeFilter(String typePatternExpression, ClassLoader classLoader) {
    this.world = new BcelWorld(classLoader, IMessageHandler.THROW, null);
    this.world.setBehaveInJava5Way(true);
    PatternParser patternParser = new PatternParser(typePatternExpression);
    TypePattern typePattern = patternParser.parseTypePattern();
    typePattern.resolve(this.world);
    IScope scope = new SimpleScope(this.world, new FormalBinding[0]);
    this.typePattern = typePattern.resolveBindings(scope, Bindings.NONE, false, false);
  }
View Full Code Here

   * @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);
      perClause = new PerCflow(pointcut, false);
View Full Code Here

    AnnotationGen decp = getAnnotation(runtimeAnnotations, AjcMemberMaker.DECLAREPARENTS_ANNOTATION);
    if (decp != null) {
      NameValuePair decpPatternNVP = getAnnotationElement(decp, VALUE);
      String decpPattern = decpPatternNVP.getValue().stringifyValue();
      if (decpPattern != null) {
        TypePattern typePattern = parseTypePattern(decpPattern, struct);
        ResolvedType fieldType = UnresolvedType.forSignature(struct.field.getSignature()).resolve(
            struct.enclosingType.getWorld());
        if (fieldType.isInterface()) {
          TypePattern parent = parseTypePattern(fieldType.getName(), struct);
          FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
          IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings);
          // first add the declare implements like
          List<TypePattern> parents = new ArrayList<TypePattern>(1);
          parents.add(parent);
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.patterns.TypePattern$MatchKind

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.