Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.DeclareParents


          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);
          DeclareParents dp = new DeclareParents(typePattern, parents, false);
          dp.resolve(binding); // resolves the parent and child parts
          // of the decp

          // resolve this so that we can use it for the
          // MethodDelegateMungers below.
          // eg. '@Coloured *' will change from a WildTypePattern to
          // an 'AnyWithAnnotationTypePattern' after this
          // resolution
          typePattern = typePattern.resolveBindings(binding, Bindings.NONE, false, false);
          // TODO kick ISourceLocation sl =
          // struct.bField.getSourceLocation(); ??
          // dp.setLocation(dp.getDeclaringType().getSourceContext(),
          // dp.getDeclaringType().getSourceLocation().getOffset(),
          // dp.getDeclaringType().getSourceLocation().getOffset());
          dp.setLocation(struct.context, -1, -1); // not ideal...
          struct.ajAttributes.add(new AjAttribute.DeclareAttribute(dp));

          // do we have a defaultImpl=xxx.class (ie implementation)
          String defaultImplClassName = null;
          NameValuePair defaultImplNVP = getAnnotationElement(decp, "defaultImpl");
View Full Code Here


    // Create the declare parents that will add the interfaces to matching targets
    FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
    IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings);
    // how do we mark this as a decp due to decmixin?
    DeclareParents dp = new DeclareParentsMixin(targetTypePattern, newParents);
    dp.resolve(binding);
    targetTypePattern = dp.getChild();

    dp.setLocation(struct.context, -1, -1); // not ideal...
    struct.ajAttributes.add(new AjAttribute.DeclareAttribute(dp));

    // The factory method for building the implementation is the
    // one attached to the annotation:
    // Method implementationFactory = struct.method;
View Full Code Here

    boolean aParentChangeOccurred = false;
    boolean anAnnotationChangeOccurred = false;
    // First pass - apply all decp mungers
    for (Iterator<DeclareParents> i = declareParentsList.iterator(); i.hasNext();) {
      DeclareParents decp = i.next();
      boolean typeChanged = applyDeclareParents(decp, onType);
      if (typeChanged) {
        aParentChangeOccurred = true;
      } else { // Perhaps it would have matched if a 'dec @type' had
        // modified the type
        if (!decp.getChild().isStarAnnotation()) {
          decpToRepeat.add(decp);
        }
      }
    }

    // Still first pass - apply all dec @type mungers
    for (Iterator i = getCrosscuttingMembersSet().getDeclareAnnotationOnTypes().iterator(); i.hasNext();) {
      DeclareAnnotation decA = (DeclareAnnotation) i.next();
      boolean typeChanged = applyDeclareAtType(decA, onType, true);
      if (typeChanged) {
        anAnnotationChangeOccurred = true;
      }
    }

    while ((aParentChangeOccurred || anAnnotationChangeOccurred) && !decpToRepeat.isEmpty()) {
      anAnnotationChangeOccurred = aParentChangeOccurred = false;
      List<DeclareParents> decpToRepeatNextTime = new ArrayList<DeclareParents>();
      for (Iterator<DeclareParents> iter = decpToRepeat.iterator(); iter.hasNext();) {
        DeclareParents decp = iter.next();
        boolean typeChanged = applyDeclareParents(decp, onType);
        if (typeChanged) {
          aParentChangeOccurred = true;
        } else {
          decpToRepeatNextTime.add(decp);
View Full Code Here

    boolean aParentChangeOccurred      = false;
    boolean anAnnotationChangeOccurred = false;
    // First pass - apply all decp mungers
    for (Iterator i = declareParentsList.iterator(); i.hasNext(); ) {
      DeclareParents decp = (DeclareParents)i.next();
      boolean typeChanged = applyDeclareParents(decp,onType);
      if (typeChanged) {
        aParentChangeOccurred = true;
      } else { // Perhaps it would have matched if a 'dec @type' had modified the type
        if (!decp.getChild().isStarAnnotation()) decpToRepeat.add(decp);
      }
    }

    // Still first pass - apply all dec @type mungers
    for (Iterator i = xcutSet.getDeclareAnnotationOnTypes().iterator();i.hasNext();) {
      DeclareAnnotation decA = (DeclareAnnotation)i.next();
      boolean typeChanged = applyDeclareAtType(decA,onType,true);
      if (typeChanged) {
        anAnnotationChangeOccurred = true;
      }
    }
   
    while ((aParentChangeOccurred || anAnnotationChangeOccurred) && !decpToRepeat.isEmpty()) {
      anAnnotationChangeOccurred = aParentChangeOccurred = false;
      List decpToRepeatNextTime = new ArrayList();
      for (Iterator iter = decpToRepeat.iterator(); iter.hasNext();) {
        DeclareParents decp = (DeclareParents) iter.next();
        boolean typeChanged = applyDeclareParents(decp,onType);
        if (typeChanged) {
          aParentChangeOccurred = true;
        } else {
          decpToRepeatNextTime.add(decp);
View Full Code Here

    } else if (declareDecl instanceof DeclareErrorOrWarning) {
      DeclareErrorOrWarning dd = (DeclareErrorOrWarning) declareDecl;
      annotation = AtAspectJAnnotationFactory
                  .createDeclareErrorOrWarningAnnotation(dd.getPointcut().toString(),dd.getMessage(),dd.isError(),declarationSourceStart);
    } else if (declareDecl instanceof DeclareParents) {
      DeclareParents dp = (DeclareParents) declareDecl;
      String childPattern = dp.getChild().toString();
      Collection parentPatterns = dp.getParents().getExactTypes();
      StringBuffer parents = new StringBuffer();
      for (Iterator iter = parentPatterns.iterator(); iter.hasNext();) {
        UnresolvedType  urt = ((UnresolvedType) iter.next());
        parents.append(urt.getName());
        if (iter.hasNext()) parents.append(", ");
      }   
      annotation = AtAspectJAnnotationFactory
                  .createDeclareParentsAnnotation(childPattern,parents.toString(),dp.isExtends(),declarationSourceStart);
    } else if (declareDecl instanceof DeclarePrecedence) {
      DeclarePrecedence dp = (DeclarePrecedence) declareDecl;
      String precedenceList = dp.getPatterns().toString();
      annotation = AtAspectJAnnotationFactory.createDeclarePrecedenceAnnotation(precedenceList,declarationSourceStart);
    } else if (declareDecl instanceof DeclareSoft) {
      DeclareSoft ds = (DeclareSoft) declareDecl;
      annotation = AtAspectJAnnotationFactory
        .createDeclareSoftAnnotation(ds.getPointcut().toString(),ds.getException().getExactType().getName(),declarationSourceStart);     
View Full Code Here

      m.setDeclaringType(declare.getDeclaringType());
      addShadowMunger(m);
    } else if (declare instanceof DeclarePrecedence) {
      declareDominates.add(declare);
    } else if (declare instanceof DeclareParents) {
      DeclareParents dp = (DeclareParents)declare;
      exposeTypes(dp.getParents().getExactTypes());
      declareParents.add(dp);
    } 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);
View Full Code Here

  public ResolvedType findAspectDeclaringParents(DeclareParents p) {
    Set keys = this.members.keySet();
    for (Iterator iter = keys.iterator(); iter.hasNext();) {
      ResolvedType element = (ResolvedType) iter.next();
      for (Iterator i = ((CrosscuttingMembers)members.get(element)).getDeclareParents().iterator(); i.hasNext(); ) {
        DeclareParents dp = (DeclareParents)i.next();
        if (dp.equals(p)) return element;
      }
    }
    return null;
  }
View Full Code Here

        node.setDetails("\"" + genDeclareMessage(deow.getMessage()) + "\"");
       
      } else if (declare.declareDecl instanceof DeclareParents) {

        node.setKind( IProgramElement.Kind.DECLARE_PARENTS);
        DeclareParents dp = (DeclareParents)declare.declareDecl;
        node.setName(name + DECLARE_PARENTS);
       
        String kindOfDP = null;
        StringBuffer details = new StringBuffer("");
        TypePattern[] newParents = dp.getParents().getTypePatterns();
        for (int i = 0; i < newParents.length; i++) {
          TypePattern tp = newParents[i];
          UnresolvedType tx = tp.getExactType();
          if (kindOfDP == null) {
            kindOfDP = "implements ";
View Full Code Here

                if (fieldType.isInterface()) {
                    TypePattern parent = new ExactTypePattern(UnresolvedType.forSignature(struct.field.getSignature()), false, false);
                    parent.resolve(struct.enclosingType.getWorld());
                    // first add the declare implements like
                    List parents = new ArrayList(1); parents.add(parent);
                    DeclareParents dp = new DeclareParents(
                            typePattern,
                            parents,
                            false
                        );
                    //TODO kick ISourceLocation sl = struct.bField.getSourceLocation();    ??
                    dp.setLocation(struct.context,0,0); // not ideal...
                    struct.ajAttributes.add(
                            new AjAttribute.DeclareAttribute(
                                    dp
                            )
                    );
View Full Code Here

    // first pass
    // try and apply all decps - if they match, then great.  If they don't then
    // check if they are starred-annotation patterns.  If they are not starred
    // annotation patterns then they might match later...remember that...
    for (Iterator i = declareParents.iterator(); i.hasNext();) {
      DeclareParents decp = (DeclareParents)i.next();
      boolean didSomething = doDeclareParents(decp, sourceType);
      if (didSomething) {
        anyNewParents = true;
      } else {
        if (!decp.getChild().isStarAnnotation()) decpToRepeat.add(decp);
      }
    }

    for (Iterator i = declareAnnotationOnTypes.iterator(); i.hasNext();) {
      DeclareAnnotation deca = (DeclareAnnotation)i.next();
      boolean didSomething = doDeclareAnnotations(deca, sourceType,true);
      if (didSomething) {
        anyNewAnnotations = true;
      } else {
        if (!deca.getTypePattern().isStar()) decaToRepeat.add(deca);
      }
    }
   
        // now lets loop over and over until we have done all we can
    while ((anyNewAnnotations || anyNewParents) &&
        (!decpToRepeat.isEmpty() || !decaToRepeat.isEmpty())) {
      anyNewParents = anyNewAnnotations = false;
      List forRemoval = new ArrayList();
      for (Iterator i = decpToRepeat.iterator(); i.hasNext();) {
        DeclareParents decp = (DeclareParents)i.next();
        boolean didSomething = doDeclareParents(decp, sourceType);
        if (didSomething) {
          anyNewParents = true;
          forRemoval.add(decp);
        }
View Full Code Here

TOP

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

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.