Package org.aspectj.org.eclipse.jdt.internal.compiler.ast

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation


      for (int index = 0; index < declaration.annotations.length; index++) {
        TypeDeclaration
            .resolveAnnotations(declaration.staticInitializerScope, declaration.annotations, declaration.binding); // force
        // annotation
        // resolution
        Annotation a = declaration.annotations[index];
        if (a.resolvedType == null) {
          continue; // another problem is being reported, so don't crash here
        }
        if (CharOperation.equals(a.resolvedType.signature(), aspectSig)) {
          return true;
View Full Code Here


    final int length = annotations.length;
    int visibleAnnotationsCounter = 0;
    int invisibleAnnotationsCounter = 0;
   
    for (int i = 0; i < length; i++) {
      Annotation annotation = annotations[i];
      if (isRuntimeInvisible(annotation)) {
        invisibleAnnotationsCounter++;
      } else if (isRuntimeVisible(annotation)) {
        visibleAnnotationsCounter++;
      }
    }

    if (invisibleAnnotationsCounter != 0) {
      int annotationAttributeOffset = contentsOffset;
      if (contentsOffset + 10 >= contents.length) {
        resizeContents(10);
      }
      int runtimeInvisibleAnnotationsAttributeNameIndex =
        constantPool.literalIndex(AttributeNamesConstants.RuntimeInvisibleAnnotationsName);
      contents[contentsOffset++] = (byte) (runtimeInvisibleAnnotationsAttributeNameIndex >> 8);
      contents[contentsOffset++] = (byte) runtimeInvisibleAnnotationsAttributeNameIndex;
      int attributeLengthOffset = contentsOffset;
      contentsOffset += 4; // leave space for the attribute length
 
      int annotationsLengthOffset = contentsOffset;
      contentsOffset += 2; // leave space for the annotations length
   
      contents[annotationsLengthOffset++] = (byte) (invisibleAnnotationsCounter >> 8);
      contents[annotationsLengthOffset++] = (byte) invisibleAnnotationsCounter;

      loop: for (int i = 0; i < length; i++) {
        if (invisibleAnnotationsCounter == 0) break loop;
        Annotation annotation = annotations[i];
        if (isRuntimeInvisible(annotation)) {
          generateAnnotation(annotation, annotationAttributeOffset);
          invisibleAnnotationsCounter--;
          if (this.contentsOffset == annotationAttributeOffset) {
            break loop;
          }
        }
      }
      if (contentsOffset != annotationAttributeOffset) {
        int attributeLength = contentsOffset - attributeLengthOffset - 4;
        contents[attributeLengthOffset++] = (byte) (attributeLength >> 24);
        contents[attributeLengthOffset++] = (byte) (attributeLength >> 16);
        contents[attributeLengthOffset++] = (byte) (attributeLength >> 8);
        contents[attributeLengthOffset++] = (byte) attributeLength;     
        attributesNumber++;
      } else {   
        contentsOffset = annotationAttributeOffset;
      }
    }
 
    if (visibleAnnotationsCounter != 0) {
      int annotationAttributeOffset = contentsOffset;
      if (contentsOffset + 10 >= contents.length) {
        resizeContents(10);
      }
      int runtimeVisibleAnnotationsAttributeNameIndex =
        constantPool.literalIndex(AttributeNamesConstants.RuntimeVisibleAnnotationsName);
      contents[contentsOffset++] = (byte) (runtimeVisibleAnnotationsAttributeNameIndex >> 8);
      contents[contentsOffset++] = (byte) runtimeVisibleAnnotationsAttributeNameIndex;
      int attributeLengthOffset = contentsOffset;
      contentsOffset += 4; // leave space for the attribute length
 
      int annotationsLengthOffset = contentsOffset;
      contentsOffset += 2; // leave space for the annotations length
   
      contents[annotationsLengthOffset++] = (byte) (visibleAnnotationsCounter >> 8);
      contents[annotationsLengthOffset++] = (byte) visibleAnnotationsCounter;

      loop: for (int i = 0; i < length; i++) {
        if (visibleAnnotationsCounter == 0) break loop;
        Annotation annotation = annotations[i];
        if (isRuntimeVisible(annotation)) {
          visibleAnnotationsCounter--;
          generateAnnotation(annotation, annotationAttributeOffset);
          if (this.contentsOffset == annotationAttributeOffset) {
            break loop;
View Full Code Here

    for (int i = 0; i < argumentsLength; i++) {
      Argument argument = arguments[i];
      Annotation[] annotations = argument.annotations;
      if (annotations != null) {
        for (int j = 0, max2 = annotations.length; j < max2; j++) {
          Annotation annotation = annotations[j];
          if (isRuntimeInvisible(annotation)) {
            annotationsCounters[i][INVISIBLE_INDEX]++;
            invisibleParametersAnnotationsCounter++;
          } else if (isRuntimeVisible(annotation)) {
            annotationsCounters[i][VISIBLE_INDEX]++;
            visibleParametersAnnotationsCounter++;
          }
        }
      }
    }
    int attributesNumber = 0;
    int annotationAttributeOffset = contentsOffset;
    if (invisibleParametersAnnotationsCounter != 0) {
      if (contentsOffset + 7 >= contents.length) {
        resizeContents(7);
      }
      int attributeNameIndex =
        constantPool.literalIndex(AttributeNamesConstants.RuntimeInvisibleParameterAnnotationsName);
      contents[contentsOffset++] = (byte) (attributeNameIndex >> 8);
      contents[contentsOffset++] = (byte) attributeNameIndex;
      int attributeLengthOffset = contentsOffset;
      contentsOffset += 4; // leave space for the attribute length

      contents[contentsOffset++] = (byte) argumentsLength;
      invisibleLoop: for (int i = 0; i < argumentsLength; i++) {
        if (contentsOffset + 2 >= contents.length) {
          resizeContents(2);
        }
        if (invisibleParametersAnnotationsCounter == 0) {
          contents[contentsOffset++] = (byte) 0;
          contents[contentsOffset++] = (byte) 0;         
        } else {
          final int numberOfInvisibleAnnotations = annotationsCounters[i][INVISIBLE_INDEX];
          contents[contentsOffset++] = (byte) (numberOfInvisibleAnnotations >> 8);
          contents[contentsOffset++] = (byte) numberOfInvisibleAnnotations;
          if (numberOfInvisibleAnnotations != 0) {
            Argument argument = arguments[i];
            Annotation[] annotations = argument.annotations;
            for (int j = 0, max = annotations.length; j < max; j++) {
              Annotation annotation = annotations[j];
              if (isRuntimeInvisible(annotation)) {
                generateAnnotation(annotation, annotationAttributeOffset);
                if (contentsOffset == annotationAttributeOffset) {
                  break invisibleLoop;
                }
                invisibleParametersAnnotationsCounter--;
              }
            }
          }
        }
      }
      if (contentsOffset != annotationAttributeOffset) {
        int attributeLength = contentsOffset - attributeLengthOffset - 4;
        contents[attributeLengthOffset++] = (byte) (attributeLength >> 24);
        contents[attributeLengthOffset++] = (byte) (attributeLength >> 16);
        contents[attributeLengthOffset++] = (byte) (attributeLength >> 8);
        contents[attributeLengthOffset++] = (byte) attributeLength;     
        attributesNumber++;
      } else {
        contentsOffset = annotationAttributeOffset;
      }
    }
    if (visibleParametersAnnotationsCounter != 0) {
      if (contentsOffset + 7 >= contents.length) {
        resizeContents(7);
      }
      int attributeNameIndex =
        constantPool.literalIndex(AttributeNamesConstants.RuntimeVisibleParameterAnnotationsName);
      contents[contentsOffset++] = (byte) (attributeNameIndex >> 8);
      contents[contentsOffset++] = (byte) attributeNameIndex;
      int attributeLengthOffset = contentsOffset;
      contentsOffset += 4; // leave space for the attribute length

      contents[contentsOffset++] = (byte) argumentsLength;
      visibleLoop: for (int i = 0; i < argumentsLength; i++) {
        if (contentsOffset + 2 >= contents.length) {
          resizeContents(2);
        }
        if (visibleParametersAnnotationsCounter == 0) {
          contents[contentsOffset++] = (byte) 0;
          contents[contentsOffset++] = (byte) 0;         
        } else {
          final int numberOfVisibleAnnotations = annotationsCounters[i][VISIBLE_INDEX];
          contents[contentsOffset++] = (byte) (numberOfVisibleAnnotations >> 8);
          contents[contentsOffset++] = (byte) numberOfVisibleAnnotations;
          if (numberOfVisibleAnnotations != 0) {
            Argument argument = arguments[i];
            Annotation[] annotations = argument.annotations;
            for (int j = 0, max = annotations.length; j < max; j++) {
              Annotation annotation = annotations[j];
              if (isRuntimeVisible(annotation)) {
                generateAnnotation(annotation, annotationAttributeOffset);
                if (contentsOffset == annotationAttributeOffset) {
                  break visibleLoop;
                }
View Full Code Here

        // TODO AV - could speed up if we could dig only for @Aspect declaring types (or aspect if mixed style allowed)
        // ??? how to : node.getParent().getKind().equals(IProgramElement.Kind.ASPECT)) {
        if (true && methodDeclaration != null && methodDeclaration.annotations != null && methodDeclaration.scope != null) {
          for (int i = 0; i < methodDeclaration.annotations.length; i++) {
            // Note: AV: implicit single advice type support here (should be enforced somewhere as well (APT etc))
            Annotation annotation = methodDeclaration.annotations[i];
            String annotationSig = new String(annotation.type.getTypeBindingPublic(methodDeclaration.scope).signature());
            if (annotationSig.charAt(1) == 'o') {
              if ("Lorg/aspectj/lang/annotation/Pointcut;".equals(annotationSig)) {
                node.setKind(IProgramElement.Kind.POINTCUT);
                node.setAnnotationStyleDeclaration(true); // pointcuts don't seem to get handled quite right...
View Full Code Here

  }

  PerClause.Kind getPerClauseForTypeDeclaration(TypeDeclaration typeDeclaration) {
    Annotation[] annotations = typeDeclaration.annotations;
    for (int i = 0; i < annotations.length; i++) {
      Annotation annotation = annotations[i];
      if (CharOperation.equals(aspectSig, annotation.resolvedType.signature())) {
        // found @Aspect(...)
        if (annotation.memberValuePairs() == null || annotation.memberValuePairs().length == 0) {
          // it is an @Aspect or @Aspect()
          // needs to use PerFromSuper if declaration extends a super
          // aspect
          PerClause.Kind kind = lookupPerClauseKind(typeDeclaration.binding.superclass);
          // if no super aspect, we have a @Aspect() means singleton
View Full Code Here

  protected abstract char[] getPrefix();
 
 
  public void addAtAspectJAnnotations() {
    if (munger == null) return;
    Annotation ann = AtAspectJAnnotationFactory.createITDAnnotation(
        munger.getSignature().getDeclaringType().getName().toCharArray(),
        declaredModifiers,declaredSelector,declarationSourceStart);
    AtAspectJAnnotationFactory.addAnnotation(this,ann,this.scope);
  }
View Full Code Here

      return true;
    } else if (decl.annotations == null) {
      return false;
    } else {
      for (int i = 0; i < decl.annotations.length; i++) {
        Annotation ann = decl.annotations[i];
        if (ann.type instanceof SingleTypeReference) {
          if (CharOperation.equals("Aspect".toCharArray(), ((SingleTypeReference) ann.type).token)) {
            return true;
          }
        } else if (ann.type instanceof QualifiedTypeReference) {
View Full Code Here

          (abits & TagBits.AnnotationRuntimeRetention) != 0), factory.getWorld()));
      CompilationAndWeavingContext.leavingPhase(tok);
      return true;
    }

    Annotation currentAnnotations[] = sourceType.scope.referenceContext.annotations;
    if (currentAnnotations != null) {
      for (int i = 0; i < currentAnnotations.length; i++) {
        Annotation annotation = currentAnnotations[i];
        String a = CharOperation.toString(annotation.type.getTypeName());
        String b = CharOperation.toString(toAdd[0].type.getTypeName());
        // FIXME asc we have a lint for attempting to add an annotation
        // twice to a method,
        // we could put it out here *if* we can resolve the problem of
        // errors coming out
        // multiple times if we have cause to loop through here
        if (a.equals(b)) {
          CompilationAndWeavingContext.leavingPhase(tok);
          return false;
        }
      }
    }

    if (((abits & TagBits.AnnotationTargetMASK) != 0)) {
      if ((abits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType)) == 0) {
        // this means it specifies something other than annotation or
        // normal type - error will have been already reported,
        // just resolution process above
        CompilationAndWeavingContext.leavingPhase(tok);
        return false;
      }
      if ((sourceType.isAnnotationType() && (abits & TagBits.AnnotationForAnnotationType) == 0)
          || (!sourceType.isAnnotationType() && (abits & TagBits.AnnotationForType) == 0)) {

        if (reportProblems) {
          if (decA.isExactPattern()) {
            factory.showMessage(IMessage.ERROR, WeaverMessages.format(
                WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION, rtx.getName(), toAdd[0].type,
                stringifyTargets(abits)), decA.getSourceLocation(), null);
          }
          // dont put out the lint - the weaving process will do that
          // else {
          // if
          // (factory.getWorld().getLint().invalidTargetForAnnotation
          // .isEnabled()) {
          // factory.getWorld().getLint().invalidTargetForAnnotation.
          // signal(new
          // String[]{rtx.getName(),toAdd[0].type.toString(),
          // stringifyTargets(abits)},decA.getSourceLocation(),null);
          // }
          // }
        }
        CompilationAndWeavingContext.leavingPhase(tok);
        return false;
      }
    }

    // Build a new array of annotations

    // remember the current set (rememberAnnotations only does something the
    // first time it is called for a type)
    sourceType.scope.referenceContext.rememberAnnotations();

    // AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(
    // decA.getSourceLocation(), rtx.getSourceLocation());
    Annotation abefore[] = sourceType.scope.referenceContext.annotations;
    Annotation[] newset = new Annotation[toAdd.length + (abefore == null ? 0 : abefore.length)];
    System.arraycopy(toAdd, 0, newset, 0, toAdd.length);
    if (abefore != null) {
      System.arraycopy(abefore, 0, newset, toAdd.length, abefore.length);
    }
View Full Code Here

      Annotation[] annos = getEclipseAnnotations();
      if (annos == null) {
        return null;
      }
      for (int i = 0; i < annos.length; i++) {
        Annotation anno = annos[i];
        UnresolvedType ut = UnresolvedType.forSignature(new String(anno.resolvedType.signature()));
        if (w.resolve(ut).equals(ofType)) {
          // Found the one
          return EclipseAnnotationConvertor.convertEclipseAnnotation(anno, w, eclipseFactory);
        }
View Full Code Here

        if (annos == null) {
          cachedAnnotationTypes = ResolvedType.EMPTY_RESOLVED_TYPE_ARRAY;
        } else {
          cachedAnnotationTypes = new ResolvedType[annos.length];
          for (int i = 0; i < annos.length; i++) {
            Annotation type = annos[i];
            TypeBinding typebinding = type.resolvedType;
            // If there was a problem resolving the annotation (the import couldn't be found) then that can manifest
            // here as typebinding == null. Normally errors are reported prior to weaving (so weaving is avoided and
            // the null is not encountered) but the use of hasfield/hasmethod can cause early attempts to look at
            // annotations and if we NPE here then the real error will not get reported.
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation

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.