Package org.aspectj.weaver.patterns

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


      ResolvedMember itdIsActually = fieldMunger.getSignature();
      List<DeclareAnnotation> worthRetrying = new ArrayList<DeclareAnnotation>();
      boolean modificationOccured = false;

      for (Iterator<DeclareAnnotation> iter2 = decaFs.iterator(); iter2.hasNext();) {
        DeclareAnnotation decaF = iter2.next();

        if (decaF.matches(itdIsActually, world)) {
          LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
          if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors)) {
            continue; // skip this one...
          }
          annotationHolder.addAnnotation(decaF.getAnnotation());
          AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
              decaF.getSourceLocation(), itdIsActually.getSourceLocation());
          isChanged = true;
          modificationOccured = true;

        } else {
          if (!decaF.isStarredAnnotationPattern()) {
            worthRetrying.add(decaF); // an annotation is specified
            // that might be put on by a
            // subsequent decaf
          }
        }
      }

      while (!worthRetrying.isEmpty() && modificationOccured) {
        modificationOccured = false;
        List<DeclareAnnotation> forRemoval = new ArrayList<DeclareAnnotation>();
        for (Iterator<DeclareAnnotation> iter2 = worthRetrying.iterator(); iter2.hasNext();) {
          DeclareAnnotation decaF = iter2.next();
          if (decaF.matches(itdIsActually, world)) {
            LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
            if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors)) {
              continue; // skip this one...
            }
            annotationHolder.addAnnotation(decaF.getAnnotation());
            AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
                decaF.getSourceLocation(), itdIsActually.getSourceLocation());
            isChanged = true;
            modificationOccured = true;
            forRemoval.add(decaF);
          }
        }
View Full Code Here


      ResolvedMember unMangledInterMethod = methodctorMunger.getSignature();
      List<DeclareAnnotation> worthRetrying = new ArrayList<DeclareAnnotation>();
      boolean modificationOccured = false;

      for (Iterator<DeclareAnnotation> iter2 = decaMCs.iterator(); iter2.hasNext();) {
        DeclareAnnotation decaMC = iter2.next();
        if (decaMC.matches(unMangledInterMethod, world)) {
          LazyMethodGen annotationHolder = locateAnnotationHolderForMethodCtorMunger(clazz, methodctorMunger);
          if (annotationHolder == null
              || doesAlreadyHaveAnnotation(annotationHolder, unMangledInterMethod, decaMC, reportedErrors)) {
            continue; // skip this one...
          }
          annotationHolder.addAnnotation(decaMC.getAnnotation());
          isChanged = true;
          AsmRelationshipProvider.addDeclareAnnotationRelationship(asmManager, decaMC.getSourceLocation(),
              unMangledInterMethod.getSourceLocation());
          reportMethodCtorWeavingMessage(clazz, unMangledInterMethod, decaMC, -1);
          modificationOccured = true;
        } else {
          // If an annotation is specified, it might be added by one of the other declare annotation statements
          if (!decaMC.isStarredAnnotationPattern()) {
            worthRetrying.add(decaMC);
          }
        }
      }

      while (!worthRetrying.isEmpty() && modificationOccured) {
        modificationOccured = false;
        List<DeclareAnnotation> forRemoval = new ArrayList<DeclareAnnotation>();
        for (Iterator<DeclareAnnotation> iter2 = worthRetrying.iterator(); iter2.hasNext();) {
          DeclareAnnotation decaMC = iter2.next();
          if (decaMC.matches(unMangledInterMethod, world)) {
            LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, methodctorMunger);
            if (doesAlreadyHaveAnnotation(annotationHolder, unMangledInterMethod, decaMC, reportedErrors)) {
              continue; // skip this one...
            }
            annotationHolder.addAnnotation(decaMC.getAnnotation());
            unMangledInterMethod.addAnnotation(decaMC.getAnnotation());
            AsmRelationshipProvider.addDeclareAnnotationRelationship(asmManager, decaMC.getSourceLocation(),
                unMangledInterMethod.getSourceLocation());
            isChanged = true;
            modificationOccured = true;
            forRemoval.add(decaMC);
          }
View Full Code Here

          while (!worthRetrying.isEmpty() && modificationOccured) {
            modificationOccured = false;
            // lets have another go
            List<DeclareAnnotation> forRemoval = new ArrayList<DeclareAnnotation>();
            for (Iterator<DeclareAnnotation> iter = worthRetrying.iterator(); iter.hasNext();) {
              DeclareAnnotation decaF = iter.next();
              if (decaF.matches(aBcelField, world)) {
                // below code is for recursive things
                if (doesAlreadyHaveAnnotation(aBcelField, decaF, reportedProblems)) {
                  // remove the declare @field since don't
                  // want an error when
                  // the annotation is already there
                  unusedDecafs.remove(decaF);
                  continue; // skip this one...
                }
                aBcelField.addAnnotation(decaF.getAnnotation());
                AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(),
                    decaF.getSourceLocation(), clazz.getName(), aBcelField);
                isChanged = true;
                modificationOccured = true;
                forRemoval.add(decaF);
                // remove the declare @field since have matched
                // against it
View Full Code Here

      // the below loop fixes the very special (and very stupid)
      // case where an aspect declares an annotation
      // on an ITD it declared on itself.
      List allDecams = weaver.getWorld().getDeclareAnnotationOnMethods();
      for (Iterator i = allDecams.iterator(); i.hasNext();) {
        DeclareAnnotation decaMC = (DeclareAnnotation) i.next();
        if (decaMC.matches(explicitConstructor, weaver.getWorld()) && mg.getEnclosingClass().getType() == aspectType) {
          mg.addAnnotation(decaMC.getAnnotation());
        }
      }
    }

    // Might have to remove the default constructor - b275032
View Full Code Here

              // Single first pass
              List worthRetrying = new ArrayList();
              boolean modificationOccured = false;
             
              for (Iterator iter = decaMs.iterator(); iter.hasNext();) {
                DeclareAnnotation decaM = (DeclareAnnotation) iter.next();
               
                if (decaM.matches(mg.getMemberView(),world)) {
                  if (doesAlreadyHaveAnnotation(mg.getMemberView(),decaM,reportedProblems)) {
                    // remove the declare @method since don't want an error when
                    // the annotation is already there
                    unusedDecams.remove(decaM);
                    continue; // skip this one...
                  }
                 
                  Annotation a = decaM.getAnnotationX().getBcelAnnotation();
                  AnnotationGen ag = new AnnotationGen(a,clazz.getConstantPoolGen(),true);
                  Method oldMethod = mg.getMethod();
                  MethodGen myGen = new MethodGen(oldMethod,clazz.getClassName(),clazz.getConstantPoolGen());
                  myGen.addAnnotation(ag);
                  Method newMethod = myGen.getMethod();
                  mg.addAnnotation(decaM.getAnnotationX());
                  members.set(memberCounter,new LazyMethodGen(newMethod,clazz));
                 
                  AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaM.getSourceLocation(),clazz.getName(),mg.getMethod());
                  reportMethodCtorWeavingMessage(clazz, mg.getMemberView(), decaM,mg.getDeclarationLineNumber());
                  isChanged = true;
                  modificationOccured = true;
            // remove the declare @method since have matched against it
                  unusedDecams.remove(decaM);                
                } else {
                  if (!decaM.isStarredAnnotationPattern())
                    worthRetrying.add(decaM); // an annotation is specified that might be put on by a subsequent decaf
                }
              }
             
              // Multiple secondary passes
              while (!worthRetrying.isEmpty() && modificationOccured) {
                modificationOccured = false;
                // lets have another go
                List forRemoval = new ArrayList();
                for (Iterator iter = worthRetrying.iterator(); iter.hasNext();) {
                  DeclareAnnotation decaM = (DeclareAnnotation) iter.next();
                  if (decaM.matches(mg.getMemberView(),world)) {
                    if (doesAlreadyHaveAnnotation(mg.getMemberView(),decaM,reportedProblems)) {
                      // remove the declare @method since don't want an error when
                        // the annotation is already there
                        unusedDecams.remove(decaM);
                      continue; // skip this one...
                    }
                    mg.addAnnotation(decaM.getAnnotationX());
                    AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaM.getSourceLocation(),clazz.getName(),mg.getMethod());
                    isChanged = true;
                    modificationOccured = true;
                    forRemoval.add(decaM);
                // remove the declare @method since have matched against it
                    unusedDecams.remove(decaM);
View Full Code Here

   * those that could possibly match on a field/method/ctor in type.
   */
  private List getMatchingSubset(List declareAnnotations, ResolvedType type) {
      List subset = new ArrayList();
      for (Iterator iter = declareAnnotations.iterator(); iter.hasNext();) {
      DeclareAnnotation da = (DeclareAnnotation) iter.next();
      if (da.couldEverMatch(type)) {
        subset.add(da);
      }
    }
    return subset;
  }
View Full Code Here

      ResolvedMember itdIsActually = fieldMunger.getSignature();
      List worthRetrying = new ArrayList();
      boolean modificationOccured = false;
     
      for (Iterator iter2 = decaFs.iterator(); iter2.hasNext();) {
        DeclareAnnotation decaF = (DeclareAnnotation) iter2.next();
       
        if (decaF.matches(itdIsActually,world)) {
          LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz,fieldMunger);
          if (doesAlreadyHaveAnnotation(annotationHolder,itdIsActually,decaF,reportedErrors)) continue; // skip this one...
          annotationHolder.addAnnotation(decaF.getAnnotationX());
          AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaF.getSourceLocation(),itdIsActually.getSourceLocation());
          isChanged = true;
          modificationOccured = true;
         
        } else {
          if (!decaF.isStarredAnnotationPattern())
            worthRetrying.add(decaF); // an annotation is specified that might be put on by a subsequent decaf
        }
      }
     
        while (!worthRetrying.isEmpty() && modificationOccured) {
        modificationOccured = false;
                List forRemoval = new ArrayList();
                for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) {
          DeclareAnnotation decaF = (DeclareAnnotation) iter2.next();
          if (decaF.matches(itdIsActually,world)) {
          LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz,fieldMunger);
          if (doesAlreadyHaveAnnotation(annotationHolder,itdIsActually,decaF,reportedErrors)) continue; // skip this one...
          annotationHolder.addAnnotation(decaF.getAnnotationX());
          AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaF.getSourceLocation(),itdIsActually.getSourceLocation());
          isChanged = true;
          modificationOccured = true;
          forRemoval.add(decaF);
          }
          worthRetrying.removeAll(forRemoval);
View Full Code Here

      ResolvedMember unMangledInterMethod = methodctorMunger.getSignature();
      List worthRetrying = new ArrayList();
      boolean modificationOccured = false;
     
      for (Iterator iter2 = decaMCs.iterator(); iter2.hasNext();) {
        DeclareAnnotation decaMC = (DeclareAnnotation) iter2.next();
        if (decaMC.matches(unMangledInterMethod,world)) {
          LazyMethodGen annotationHolder = locateAnnotationHolderForMethodCtorMunger(clazz,methodctorMunger);
          if (annotationHolder == null || doesAlreadyHaveAnnotation(annotationHolder,unMangledInterMethod,decaMC,reportedErrors)){
            continue; // skip this one...
          }
          annotationHolder.addAnnotation(decaMC.getAnnotationX());
          isChanged=true;
          AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaMC.getSourceLocation(),unMangledInterMethod.getSourceLocation());
          reportMethodCtorWeavingMessage(clazz, unMangledInterMethod, decaMC,-1);
          modificationOccured = true;         
        } else {
          if (!decaMC.isStarredAnnotationPattern())
            worthRetrying.add(decaMC); // an annotation is specified that might be put on by a subsequent decaf
        }
      }
     
        while (!worthRetrying.isEmpty() && modificationOccured) {
        modificationOccured = false;
                List forRemoval = new ArrayList();
                for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) {
          DeclareAnnotation decaMC = (DeclareAnnotation) iter2.next();
          if (decaMC.matches(unMangledInterMethod,world)) {
          LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz,methodctorMunger);
          if (doesAlreadyHaveAnnotation(annotationHolder,unMangledInterMethod,decaMC,reportedErrors)) continue; // skip this one...
          annotationHolder.addAnnotation(decaMC.getAnnotationX());
          unMangledInterMethod.addAnnotation(decaMC.getAnnotationX());
          AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaMC.getSourceLocation(),unMangledInterMethod.getSourceLocation());
          isChanged = true;
          modificationOccured = true;
          forRemoval.add(decaMC);
          }
          worthRetrying.removeAll(forRemoval);
View Full Code Here

           
            Annotation [] dontAddMeTwice = fields[fieldCounter].getAnnotations();
           
            // go through all the declare @field statements
            for (Iterator iter = decaFs.iterator(); iter.hasNext();) {
        DeclareAnnotation decaF = (DeclareAnnotation) iter.next();
        if (decaF.matches(aBcelField,world)) {
         
          if (!dontAddTwice(decaF,dontAddMeTwice)){
            if (doesAlreadyHaveAnnotation(aBcelField,decaF,reportedProblems)){
                    // remove the declare @field since don't want an error when
                    // the annotation is already there
                    unusedDecafs.remove(decaF);
              continue;
            }
           
            if(decaF.getAnnotationX().isRuntimeVisible()){ // isAnnotationWithRuntimeRetention(clazz.getJavaClass(world))){
            //if(decaF.getAnnotationTypeX().isAnnotationWithRuntimeRetention(world)){           
              // it should be runtime visible, so put it on the Field
              Annotation a = decaF.getAnnotationX().getBcelAnnotation();
              AnnotationGen ag = new AnnotationGen(a,clazz.getConstantPoolGen(),true);
              FieldGen myGen = new FieldGen(fields[fieldCounter],clazz.getConstantPoolGen());
              myGen.addAnnotation(ag);
              Field newField = myGen.getField();
             
              aBcelField.addAnnotation(decaF.getAnnotationX());
              clazz.replaceField(fields[fieldCounter],newField);
              fields[fieldCounter]=newField;
             
            } else{
              aBcelField.addAnnotation(decaF.getAnnotationX());
            }
          }
         
          AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaF.getSourceLocation(),clazz.getName(),fields[fieldCounter]);
          reportFieldAnnotationWeavingMessage(clazz, fields, fieldCounter, decaF);   
          isChanged = true;
          modificationOccured = true;
          // remove the declare @field since have matched against it
              unusedDecafs.remove(decaF);
        } else {
          if (!decaF.isStarredAnnotationPattern())
            worthRetrying.add(decaF); // an annotation is specified that might be put on by a subsequent decaf
        }
      }
     
            // Multiple secondary passes
            while (!worthRetrying.isEmpty() && modificationOccured) {
              modificationOccured = false;
              // lets have another go
              List forRemoval = new ArrayList();
              for (Iterator iter = worthRetrying.iterator(); iter.hasNext();) {
        DeclareAnnotation decaF = (DeclareAnnotation) iter.next();
        if (decaF.matches(aBcelField,world)) {
          // below code is for recursive things
          if (doesAlreadyHaveAnnotation(aBcelField,decaF,reportedProblems)) {
                // remove the declare @field since don't want an error when
                // the annotation is already there
                unusedDecafs.remove(decaF);
            continue; // skip this one...
          }
          aBcelField.addAnnotation(decaF.getAnnotationX());
          AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaF.getSourceLocation(),clazz.getName(),fields[fieldCounter]);
          isChanged = true;
          modificationOccured = true;
          forRemoval.add(decaF);
          // remove the declare @field since have matched against it
              unusedDecafs.remove(decaF);
View Full Code Here

   * match and a flag indicating whether the set contains declare @field or declare @method/ctor
   * entries.
   */
  private void checkUnusedDeclareAtTypes(Set unusedDecaTs, boolean isDeclareAtField) {
    for (Iterator iter = unusedDecaTs.iterator(); iter.hasNext();) {
        DeclareAnnotation declA = (DeclareAnnotation) iter.next();
       
        // Error if an exact type pattern was specified
        if ((declA.isExactPattern() ||
          (declA.getSignaturePattern().getDeclaringType() instanceof ExactTypePattern))
          && (!declA.getSignaturePattern().getName().isAny()
              || (declA.getKind() == DeclareAnnotation.AT_CONSTRUCTOR))) {
         
          // Quickly check if an ITD meets supplies the 'missing' member
          boolean itdMatch = false;
          List lst = clazz.getType().getInterTypeMungers();
          for (Iterator iterator = lst.iterator(); iterator.hasNext() && !itdMatch;) {
          BcelTypeMunger element = (BcelTypeMunger) iterator.next();
          if (element.getMunger() instanceof NewFieldTypeMunger) {
            NewFieldTypeMunger nftm = (NewFieldTypeMunger)element.getMunger();
            itdMatch = declA.getSignaturePattern().matches(nftm.getSignature(),world,false);
            }else if (element.getMunger() instanceof NewMethodTypeMunger) {
            NewMethodTypeMunger nmtm = (NewMethodTypeMunger)element.getMunger();
            itdMatch = declA.getSignaturePattern().matches(nmtm.getSignature(),world,false);             
          } else if (element.getMunger() instanceof NewConstructorTypeMunger) {
            NewConstructorTypeMunger nctm = (NewConstructorTypeMunger)element.getMunger();
            itdMatch = declA.getSignaturePattern().matches(nctm.getSignature(),world,false);             
          }
        }
          if (!itdMatch) {
            IMessage message = null;
            if (isDeclareAtField) {
              message = new Message(
                "The field '"+ declA.getSignaturePattern().toString() +
                "' does not exist", declA.getSourceLocation() , true);
          } else {
            message = new Message(
                "The method '"+ declA.getSignaturePattern().toString() +
                "' does not exist", declA.getSourceLocation() , true);
          }
          world.getMessageHandler().handleMessage(message);         
        }
        }
      }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.patterns.DeclareAnnotation$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.