Beispiel #1
0
  public static Annotation copyAnnotation(Annotation annotation, ASTNode source) {
    int pS = source.sourceStart, pE = source.sourceEnd;

    if (annotation instanceof MarkerAnnotation) {
      MarkerAnnotation ann = new MarkerAnnotation(copyType(annotation.type, source), pS);
      setGeneratedBy(ann, source);
      ann.declarationSourceEnd = ann.sourceEnd = ann.statementEnd = pE;
      return ann;
    }

    if (annotation instanceof SingleMemberAnnotation) {
      SingleMemberAnnotation ann =
          new SingleMemberAnnotation(copyType(annotation.type, source), pS);
      setGeneratedBy(ann, source);
      ann.declarationSourceEnd = ann.sourceEnd = ann.statementEnd = pE;
      // TODO memberValue(s) need to be copied as well (same for copying a NormalAnnotation as
      // below).
      ann.memberValue = ((SingleMemberAnnotation) annotation).memberValue;
      return ann;
    }

    if (annotation instanceof NormalAnnotation) {
      NormalAnnotation ann = new NormalAnnotation(copyType(annotation.type, source), pS);
      setGeneratedBy(ann, source);
      ann.declarationSourceEnd = ann.statementEnd = ann.sourceEnd = pE;
      ann.memberValuePairs = ((NormalAnnotation) annotation).memberValuePairs;
      return ann;
    }

    return annotation;
  }
 public int resolveLevel(ASTNode possibleMatchingNode) {
   if (this.pattern.findReferences) {
     if (possibleMatchingNode instanceof MessageSend) {
       return resolveLevel((MessageSend) possibleMatchingNode);
     }
     if (possibleMatchingNode instanceof SingleMemberAnnotation) {
       SingleMemberAnnotation annotation = (SingleMemberAnnotation) possibleMatchingNode;
       return resolveLevel(annotation.memberValuePairs()[0].binding);
     }
     if (possibleMatchingNode instanceof MemberValuePair) {
       MemberValuePair memberValuePair = (MemberValuePair) possibleMatchingNode;
       return resolveLevel(memberValuePair.binding);
     }
   }
   if (this.pattern.findDeclarations) {
     if (possibleMatchingNode instanceof MethodDeclaration) {
       return resolveLevel(((MethodDeclaration) possibleMatchingNode).binding);
     }
   }
   return IMPOSSIBLE_MATCH;
 }