Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.DeclareParents


      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
View Full Code Here


      // the up front comparison
      if (!careAboutShadowMungers) {
        // this means we are in front end compilation and if the differences are purely mixin parents, we can continue OK
        Set<DeclareParents> trimmedThis = new HashSet<DeclareParents>();
        for (Iterator<DeclareParents> iterator = declareParents.iterator(); iterator.hasNext();) {
          DeclareParents decp = iterator.next();
          if (!decp.isMixin()) {
            trimmedThis.add(decp);
          }
        }
        Set<DeclareParents> trimmedOther = new HashSet<DeclareParents>();
        for (Iterator<DeclareParents> iterator = other.declareParents.iterator(); iterator.hasNext();) {
          DeclareParents decp = iterator.next();
          if (!decp.isMixin()) {
            trimmedOther.add(decp);
          }
        }
        if (!trimmedThis.equals(trimmedOther)) {
          changed = true;
View Full Code Here

        node.setDetails("\"" + AsmRelationshipUtils.genDeclareMessage(deow.getMessage()) + "\"");

      } else if (declare.declareDecl instanceof DeclareParents) {

        node.setKind(IProgramElement.Kind.DECLARE_PARENTS);
        DeclareParents dp = (DeclareParents) declare.declareDecl;
        node.setName(name + AsmRelationshipUtils.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

    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 (DeclareAnnotation decA : getCrosscuttingMembersSet().getDeclareAnnotationOnTypes()) {
      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

        StringLiteral message = new StringLiteral(this.ast);
        message.setEscapedValue(updateString(deow.getMessage()));
        ((DeclareWarningDeclaration) declareDeclaration).setMessage(message);
      }
    } else if (declare instanceof DeclareParents) {
      DeclareParents dp = (DeclareParents) declare;
      declareDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.DeclareParentsDeclaration(this.ast, dp.isExtends());
      org.aspectj.org.eclipse.jdt.core.dom.PatternNode pNode = convert(dp.getChild());
      if (pNode instanceof org.aspectj.org.eclipse.jdt.core.dom.TypePattern) {
        ((DeclareParentsDeclaration) declareDeclaration)
            .setChildTypePattern((org.aspectj.org.eclipse.jdt.core.dom.TypePattern) pNode);
      }
      TypePattern[] weaverTypePatterns = dp.getParents().getTypePatterns();
      List typePatterns = ((DeclareParentsDeclaration) declareDeclaration).parentTypePatterns();
      for (int i = 0; i < weaverTypePatterns.length; i++) {
        typePatterns.add(convert(weaverTypePatterns[i]));
      }
    } else if (declare instanceof DeclarePrecedence) {
      declareDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.DeclarePrecedenceDeclaration(this.ast);
      DeclarePrecedence dp = (DeclarePrecedence) declare;
      TypePattern[] weaverTypePatterns = dp.getPatterns().getTypePatterns();
      List typePatterns = ((DeclarePrecedenceDeclaration) declareDeclaration).typePatterns();
      for (int i = 0; i < weaverTypePatterns.length; i++) {
        typePatterns.add(convert(weaverTypePatterns[i]));
      }
    } else if (declare instanceof DeclareSoft) {
View Full Code Here

    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

          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

      if (ad.concreteName != null) {
        List declares = ad.concreteName.declares;
        for (Iterator iter = declares.iterator(); iter.hasNext();) {
          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;
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

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.