Package com.sun.source.tree

Examples of com.sun.source.tree.AnnotationTree


    CompilationUnitTree unitTree = path.getCompilationUnit();
    LineMap lineMap = unitTree.getLineMap();
    SourcePositions positions = treeUtils.getSourcePositions();

    AnnotationTree annotationTree = (AnnotationTree) path.getLeaf();
    AssignmentTree assignTree =
        (AssignmentTree) annotationTree.getArguments().get(0);
    ExpressionTree exprTree = assignTree.getExpression();

    ArrayList<Long> lines = new ArrayList<Long>();
    if (exprTree.getKind() == Kind.STRING_LITERAL) {
      long pos = positions.getStartPosition(unitTree, exprTree);
View Full Code Here


  private Description tryToReplaceAnnotation(MethodTree methodTree, VisitorState state,
                                             String badAnnotation, String goodAnnotation) {
    String finalName = getUnqualifiedClassName(goodAnnotation);
    if (hasAnnotation(badAnnotation).matches(methodTree, state)) {
      AnnotationTree annotationTree = findAnnotation(methodTree, state, badAnnotation);
      return describeMatch(annotationTree, SuggestedFix.builder()
          .addImport(goodAnnotation)
          .replace(annotationTree, "@" + finalName)
          .build());
    } else {
View Full Code Here

    return goodAnnotation.substring(goodAnnotation.lastIndexOf(".") + 1);
  }

  private AnnotationTree findAnnotation(MethodTree methodTree, VisitorState state,
                                        String annotationName) {
    AnnotationTree annotationNode = null;
    for (AnnotationTree annotation : methodTree.getModifiers().getAnnotations()) {
      if (ASTHelpers.getSymbol(annotation)
          .equals(state.getSymbolFromString(annotationName))) {
        annotationNode = annotation;
      }
View Full Code Here

          .addImport("java.lang.annotation.Retention")
          .addStaticImport("java.lang.annotation.RetentionPolicy.RUNTIME")
          .prefixWith(classTree, "@Retention(RUNTIME)\n")
          .build());
    }
    AnnotationTree retentionNode = null;
    for (AnnotationTree annotation : classTree.getModifiers().getAnnotations()) {
      if (ASTHelpers.getSymbol(annotation)
          .equals(state.getSymbolFromString(RETENTION_ANNOTATION))) {
        retentionNode = annotation;
      }
View Full Code Here

          .addStaticImport("java.lang.annotation.ElementType.TYPE")
          .addStaticImport("java.lang.annotation.ElementType.METHOD")
          .prefixWith(classTree, "@Target({TYPE, METHOD})\n")
          .build());
    }
    AnnotationTree targetNode = null;
    for (AnnotationTree annotation : classTree.getModifiers().getAnnotations()) {
      if (ASTHelpers.getSymbol(annotation).equals(state.getSymbolFromString(TARGET_ANNOTATION))) {
        targetNode = annotation;
      }
    }
View Full Code Here

  public final Description matchClass(ClassTree classTree, VisitorState state) {
    if (!MATCHER.matches(classTree, state)) {
      return Description.NO_MATCH;
    }

    AnnotationTree annotationWithScopeAnnotation = classAnnotationMatcher.getMatchingNode();
    if (annotationWithScopeAnnotation == null) {
      throw new IllegalStateException("Expected to find an annotation that was annotated " +
          "with @ScopeAnnotation");
    }
View Full Code Here

TOP

Related Classes of com.sun.source.tree.AnnotationTree

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.