Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.DeclareAnnotation


      declareSofts.add(new DeclareSoft(d.getException(), concretePointcut));
      addConcreteShadowMunger(m);
    } else if (declare instanceof DeclareAnnotation) {
      // FIXME asc perf Possible Improvement. Investigate why this is
      // called twice in a weave ?
      DeclareAnnotation da = (DeclareAnnotation) declare;
      if (da.getAspect() == null) {
        da.setAspect(inAspect);
      }
      if (da.isDeclareAtType()) {
        declareAnnotationsOnType.add(da);
      } else if (da.isDeclareAtField()) {
        declareAnnotationsOnField.add(da);
      } else if (da.isDeclareAtMethod() || da.isDeclareAtConstuctor()) {
        declareAnnotationsOnMethods.add(da);
      }
    } else if (declare instanceof DeclareTypeErrorOrWarning) {
      declareTypeEow.add((DeclareTypeErrorOrWarning) declare);
    } else {
View Full Code Here


        DeclarePrecedence ds = (DeclarePrecedence) declare.declareDecl;
        node.setName(name + AsmRelationshipUtils.DECLARE_PRECEDENCE);
        node.setDetails(genPrecedenceListLabel(ds.getPatterns()));

      } else if (declare.declareDecl instanceof DeclareAnnotation) {
        DeclareAnnotation deca = (DeclareAnnotation) declare.declareDecl;
        String thekind = deca.getKind().toString();
        node.setName(name + "@" + thekind.substring(3));

        if (deca.getKind() == DeclareAnnotation.AT_CONSTRUCTOR) {
          node.setKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR);
        } else if (deca.getKind() == DeclareAnnotation.AT_FIELD) {
          node.setKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD);
        } else if (deca.getKind() == DeclareAnnotation.AT_METHOD) {
          node.setKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD);
        } else if (deca.getKind() == DeclareAnnotation.AT_TYPE) {
          node.setKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_TYPE);
        }
        node.setDetails(genDecaLabel(deca));

      } else {
View Full Code Here

          decpToRepeatNextTime.add(decp);
        }
      }

      for (Iterator iter = getCrosscuttingMembersSet().getDeclareAnnotationOnTypes().iterator(); iter.hasNext();) {
        DeclareAnnotation decA = (DeclareAnnotation) iter.next();
        boolean typeChanged = applyDeclareAtType(decA, onType, false);
        if (typeChanged) {
          anAnnotationChangeOccurred = true;
        }
      }
View Full Code Here

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

      for (Iterator<DeclareAnnotation> iter2 = decaFs.iterator(); iter2.hasNext();) {
        DeclareAnnotation decaF = iter2.next();
        if (decaF.matches(itdIsActually, world)) {
          if (decaF.isRemover()) {
            LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
            if (annotationHolder.hasAnnotation(decaF.getAnnotationType())) {
              isChanged = true;
              // something to remove
              annotationHolder.removeAnnotation(decaF.getAnnotationType());
              AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
                  decaF.getSourceLocation(), itdIsActually.getSourceLocation(), true);
            } else {
              worthRetrying.add(decaF);
            }
          } else {

            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(), false);
            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)) {
            if (decaF.isRemover()) {
              LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
              if (annotationHolder.hasAnnotation(decaF.getAnnotationType())) {
                isChanged = true;
                // something to remove
                annotationHolder.removeAnnotation(decaF.getAnnotationType());
                AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
                    decaF.getSourceLocation(), itdIsActually.getSourceLocation(), true);
                forRemoval.add(decaF);
              }
            } else {
              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(), false);
              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(), false);
          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(), false);
            isChanged = true;
            modificationOccured = true;
            forRemoval.add(decaMC);
          }
View Full Code Here

          while (!worthRetrying.isEmpty() && modificationOccured) {
            modificationOccured = false;
            // lets have another go with any remaining ones
            List<DeclareAnnotation> forRemoval = new ArrayList<DeclareAnnotation>();
            for (Iterator<DeclareAnnotation> iter = worthRetrying.iterator(); iter.hasNext();) {
              DeclareAnnotation decaF = iter.next();

              if (decaF.matches(field, world)) {
                if (decaF.isRemover()) {
                  AnnotationAJ annotation = decaF.getAnnotation();
                  if (field.hasAnnotation(annotation.getType())) {
                    // something to remove
                    typeIsChanged = modificationOccured = true;
                    forRemoval.add(decaF);
                    field.removeAnnotation(annotation);
                    AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(),
                        decaF.getSourceLocation(), clazz.getName(), field, true);
                    reportFieldAnnotationWeavingMessage(clazz, field, decaF, true);
                  }
                } else {
                  // below code is for recursive things
                  unusedDecafs.remove(decaF);
                  if (doesAlreadyHaveAnnotation(field, decaF, reportedProblems)) {
                    continue;
                  }
                  field.addAnnotation(decaF.getAnnotation());
                  AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(),
                      decaF.getSourceLocation(), clazz.getName(), field, false);
                  typeIsChanged = modificationOccured = true;
                  forRemoval.add(decaF);
                }
              }
            }
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<DeclareAnnotation> allDecams = weaver.getWorld().getDeclareAnnotationOnMethods();
      for (Iterator<DeclareAnnotation> i = allDecams.iterator(); i.hasNext();) {
        DeclareAnnotation decaMC = 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

  public ASTNode convert(DeclareDeclaration declareDecl) {
    checkCanceled(); // is this line needed?
    org.aspectj.org.eclipse.jdt.core.dom.DeclareDeclaration declareDeclaration = null;
    Declare declare = declareDecl.declareDecl;
    if (declare instanceof DeclareAnnotation) {
      DeclareAnnotation da = (DeclareAnnotation) declare;
      if (da.getKind().equals(DeclareAnnotation.AT_TYPE)) {
        declareDeclaration = new DeclareAtTypeDeclaration(this.ast);
        ((DeclareAtTypeDeclaration) declareDeclaration).setPatternNode(convert(da.getTypePattern()));
        SimpleName annotationName = new SimpleName(this.ast);
        annotationName.setSourceRange(da.getAnnotationSourceStart(),
            da.getAnnotationSourceEnd() - da.getAnnotationSourceStart());
        annotationName.internalSetIdentifier(da.getAnnotationString());
        ((DeclareAtTypeDeclaration) declareDeclaration).setAnnotationName(annotationName);
      } else if (da.getKind().equals(DeclareAnnotation.AT_CONSTRUCTOR)) {
        declareDeclaration = new DeclareAtConstructorDeclaration(this.ast);
        ((DeclareAtConstructorDeclaration) declareDeclaration).setPatternNode(convertSignature(da.getSignaturePattern()));
        SimpleName annotationName = new SimpleName(this.ast);
        annotationName.setSourceRange(da.getAnnotationSourceStart(),
            da.getAnnotationSourceEnd() - da.getAnnotationSourceStart());
        annotationName.internalSetIdentifier(da.getAnnotationString());
        ((DeclareAtConstructorDeclaration) declareDeclaration).setAnnotationName(annotationName);
      } else if (da.getKind().equals(DeclareAnnotation.AT_FIELD)) {
        declareDeclaration = new DeclareAtFieldDeclaration(this.ast);
        ((DeclareAtFieldDeclaration) declareDeclaration).setPatternNode(convertSignature(da.getSignaturePattern()));
        SimpleName annotationName = new SimpleName(this.ast);
        annotationName.setSourceRange(da.getAnnotationSourceStart(),
            da.getAnnotationSourceEnd() - da.getAnnotationSourceStart());
        annotationName.internalSetIdentifier(da.getAnnotationString());
        ((DeclareAtFieldDeclaration) declareDeclaration).setAnnotationName(annotationName);
      } else if (da.getKind().equals(DeclareAnnotation.AT_METHOD)) {
        declareDeclaration = new DeclareAtMethodDeclaration(this.ast);
        ((DeclareAtMethodDeclaration) declareDeclaration).setPatternNode(convertSignature(da.getSignaturePattern()));
        SimpleName annotationName = new SimpleName(this.ast);
        annotationName.setSourceRange(da.getAnnotationSourceStart(),
            da.getAnnotationSourceEnd() - da.getAnnotationSourceStart());
        annotationName.internalSetIdentifier(da.getAnnotationString());
        ((DeclareAtMethodDeclaration) declareDeclaration).setAnnotationName(annotationName);
      }
    } else if (declare instanceof DeclareErrorOrWarning) {
      DeclareErrorOrWarning deow = (DeclareErrorOrWarning) declare;
      if (deow.isError()) {
View Full Code Here

          parents.add(tpl.get(i).getExactType().getName().replaceAll("\\$", "."));
        }
        peNode.setParentTypes(parents);
      }
      if (decl instanceof DeclareAnnotation) {
        DeclareAnnotation da = (DeclareAnnotation) decl;
        ResolvedType annotationType = da.getAnnotationType();
        if (annotationType == null) {
          String s = ((DeclareAnnotation) decl).getAnnotationString();
          if (s != null && s.length() > 0) {
            s = s.substring(1);
          }
          peNode.setAnnotationType(s);
        } else {
          peNode.setAnnotationType(annotationType.getName());
        }
        if (da.isRemover()) {
          peNode.setAnnotationRemover(true);
        }
      }
    }
    if (methodDeclaration.returnType != null) {
View Full Code Here

    return new DeclareDeclaration(result, declare);
  }

  public MethodDeclaration createDeclareAnnotationDeclaration(CompilationResult result, ASTNode pseudoTokens,
      Annotation annotation, Parser parser, char kind) {
    DeclareAnnotation declare = (DeclareAnnotation) ((PseudoTokens) pseudoTokens).parseAnnotationDeclare(parser);
    if (declare != null) {
      if (kind == '-') {
        declare.setRemover(true);
      }
    }
    DeclareAnnotationDeclaration decl = new DeclareAnnotationDeclaration(result, declare, annotation);
    return decl;
  }
View Full Code Here

TOP

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

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.