Java 类com.sun.source.tree.AnnotatedTypeTree 实例源码

项目:checker-framework    文件:TypeFromTree.java   
@Override
public AnnotatedTypeMirror visitAnnotatedType(AnnotatedTypeTree node,
        AnnotatedTypeFactory f) {
    AnnotatedTypeMirror type = visit(node.getUnderlyingType(), f);
    if (type == null) // e.g., for receiver type
        type = f.toAnnotatedType(f.types.getNoType(TypeKind.NONE));
    assert AnnotatedTypeFactory.validAnnotatedType(type);
    List<? extends AnnotationMirror> annos = InternalUtils.annotationsFromTree(node);
    type.addAnnotations(annos);

    if (type.getKind() == TypeKind.TYPEVAR) {
        ((AnnotatedTypeVariable)type).getUpperBound().addMissingAnnotations(annos);
    }

    if (type.getKind() == TypeKind.WILDCARD) {
        ((AnnotatedWildcardType)type).getExtendsBound().addMissingAnnotations(annos);
    }

    return type;
}
项目:incubator-netbeans    文件:TreeDuplicator.java   
@Override
public Tree visitAnnotatedType(AnnotatedTypeTree tree, Void p) {
    AnnotatedTypeTree n = make.AnnotatedType(tree.getAnnotations(), tree.getUnderlyingType());
    comments.copyComments(tree, n);
    model.setPos(n, model.getPos(tree));
    return n;
}
项目:incubator-netbeans    文件:Utilities.java   
private static Token<JavaTokenId> createHighlightImpl(CompilationInfo info, Document doc, TreePath tree) {
    Tree leaf = tree.getLeaf();
    SourcePositions positions = info.getTrees().getSourcePositions();
    CompilationUnitTree cu = info.getCompilationUnit();

    //XXX: do not use instanceof:
    if (leaf instanceof MethodTree || leaf instanceof VariableTree || leaf instanceof ClassTree
            || leaf instanceof MemberSelectTree || leaf instanceof AnnotatedTypeTree || leaf instanceof MemberReferenceTree) {
        return findIdentifierSpan(info, doc, tree);
    }

    int start = (int) positions.getStartPosition(cu, leaf);
    int end = (int) positions.getEndPosition(cu, leaf);

    if (start == Diagnostic.NOPOS || end == Diagnostic.NOPOS) {
        return null;
    }

    TokenHierarchy<?> th = info.getTokenHierarchy();
    TokenSequence<JavaTokenId> ts = th.tokenSequence(JavaTokenId.language());

    if (ts.move(start) == Integer.MAX_VALUE) {
        return null;
    }

    if (ts.moveNext()) {
        Token<JavaTokenId> token = ts.token();
        if (ts.offset() == start && token != null) {
            final JavaTokenId id = token.id();
            if (id == JavaTokenId.IDENTIFIER) {
                return token;
            }
            if (id == JavaTokenId.THIS || id == JavaTokenId.SUPER) {
                return ts.offsetToken();
            }
        }
    }

    return null;
}
项目:incubator-netbeans    文件:TreeNode.java   
@Override
public Void visitAnnotatedType(AnnotatedTypeTree tree, List<Node> d) {
    List<Node> below = new ArrayList<Node>();

    addCorrespondingElement(below);
    addCorrespondingType(below);
    addCorrespondingComments(below);

    super.visitAnnotatedType(tree, below);

    d.add(new TreeNode(info, getCurrentPath(), below));
    return null;
}
项目:annotation-tools    文件:GenericArrayLocationCriterion.java   
private boolean isGenericOrArray(Tree t) {
  return ((t.getKind() == Tree.Kind.PARAMETERIZED_TYPE)
          || (t.getKind() == Tree.Kind.ARRAY_TYPE)
          || (t.getKind() == Tree.Kind.EXTENDS_WILDCARD)
          || (t.getKind() == Tree.Kind.SUPER_WILDCARD)
          || (t.getKind() == Tree.Kind.ANNOTATED_TYPE &&
                  isGenericOrArray(((AnnotatedTypeTree)t).getUnderlyingType()))
          // Monolithic:  one node for entire "new".  So, handle specially.
          // || (t.getKind() == Tree.Kind.NEW_ARRAY)
          );
}
项目:annotation-tools    文件:ASTPathCriterion.java   
private boolean checkTypePath(int i, Tree typeTree) {
        try {
loop:       while (typeTree != null && i < astPath.size()) {
                ASTPath.ASTEntry entry = astPath.get(i);
                Tree.Kind kind = entry.getTreeKind();
                switch (kind) {
                case ANNOTATED_TYPE:
                    typeTree = ((AnnotatedTypeTree) typeTree)
                        .getUnderlyingType();
                    continue;
                case ARRAY_TYPE:
                    typeTree = ((ArrayTypeTree) typeTree).getType();
                    break;
                case MEMBER_SELECT:
                    typeTree = ((MemberSelectTree) typeTree).getExpression();
                    break;
                case PARAMETERIZED_TYPE:
                    if (entry.childSelectorIs(ASTPath.TYPE_ARGUMENT)) {
                        int arg = entry.getArgument();
                        typeTree = ((ParameterizedTypeTree) typeTree)
                                .getTypeArguments().get(arg);
                    } else {  // TYPE
                        typeTree = ((ParameterizedTypeTree) typeTree).getType();
                    }
                    break;
                default:
                    if (isWildcard(kind)) {
                        return ++i == astPath.size();  // ???
                    }
                    break loop;
                }
                ++i;
            }
        } catch (RuntimeException ex) {}
        return false;
    }
项目:annotation-tools    文件:Insertions.java   
/**
   * Returns the depth of type nesting of the innermost nested type of a type AST.
   * For example, both {@code A.B.C} and {@code A.B<D.E.F.G>.C} have depth 3.
   */
  private int localDepth(Tree node) {
    Tree t = node;
    int result = 0;
loop:
    while (t != null) {
      switch (t.getKind()) {
      case ANNOTATED_TYPE:
        t = ((AnnotatedTypeTree) t).getUnderlyingType();
        break;
      case MEMBER_SELECT:
        if (t instanceof JCTree.JCFieldAccess) {
          JCTree.JCFieldAccess jfa = (JCTree.JCFieldAccess) t;
          if (jfa.sym.kind == Kinds.PCK) {
            t = jfa.getExpression();
            continue;
          }
        }
        t = ((MemberSelectTree) t).getExpression();
        ++result;
        break;
      default:
        break loop;
      }
    }
    return result;
  }
项目:error-prone    文件:ErrorProneScanner.java   
@Override
public Void visitAnnotatedType(AnnotatedTypeTree tree, VisitorState visitorState) {
  VisitorState state = visitorState.withPath(getCurrentPath());
  for (AnnotatedTypeTreeMatcher matcher : annotatedTypeMatchers) {
    if (!isSuppressed(matcher, state)) {
      try {
        reportMatch(matcher.matchAnnotatedType(tree, state), tree, state);
      } catch (Throwable t) {
        handleError(matcher, t);
      }
    }
  }
  return super.visitAnnotatedType(tree, state);
}
项目:checker-framework    文件:TreeUtils.java   
/**
 * Returns true if the tree is of a diamond type.
 * In contrast to the implementation in TreeInfo, this version
 * works on Trees.
 *
 * @see com.sun.tools.javac.tree.TreeInfo#isDiamond(JCTree)
 */
public static final boolean isDiamondTree(Tree tree) {
    switch (tree.getKind()) {
    case ANNOTATED_TYPE: return isDiamondTree(((AnnotatedTypeTree)tree).getUnderlyingType());
    case PARAMETERIZED_TYPE: return ((ParameterizedTypeTree)tree).getTypeArguments().isEmpty();
    case NEW_CLASS: return isDiamondTree(((NewClassTree)tree).getIdentifier());
    default: return false;
    }
}
项目:checker-framework    文件:NullnessVisitor.java   
@Override
public Void visitNewClass(NewClassTree node, Void p) {
    AnnotatedDeclaredType type = atypeFactory.getAnnotatedType(node);
    ExpressionTree identifier = node.getIdentifier();
    if (identifier instanceof AnnotatedTypeTree) {
        AnnotatedTypeTree t = (AnnotatedTypeTree) identifier;
        for (AnnotationMirror a : atypeFactory.getAnnotatedType(t).getAnnotations()) {
            // is this an annotation of the nullness checker?
            boolean nullnessCheckerAnno = containsSameIgnoringValues(
                            atypeFactory.getNullnessAnnotations(), a);
            if (nullnessCheckerAnno && !AnnotationUtils.areSame(NONNULL, a)) {
                // The type is not non-null => warning
                checker.report(
                        Result.warning("new.class.type.invalid",
                                type.getAnnotations()), node);
                // Note that other consistency checks are made by isValid.
            }
        }
        if (t.toString().contains("@PolyNull")) {
            // TODO: this is a hack, but PolyNull gets substituted
            // afterwards
            checker.report(
                    Result.warning("new.class.type.invalid",
                            type.getAnnotations()), node);
        }
    }
    // TODO: It might be nicer to introduce a framework-level
    // isValidNewClassType or some such.
    return super.visitNewClass(node, p);
}
项目:bazel    文件:TreeUtils.java   
/**
 * Returns true if the tree is of a diamond type. In contrast to the implementation in TreeInfo,
 * this version works on Trees.
 *
 * @see com.sun.tools.javac.tree.TreeInfo#isDiamond(JCTree)
 */
public static final boolean isDiamondTree(Tree tree) {
    switch (tree.getKind()) {
        case ANNOTATED_TYPE:
            return isDiamondTree(((AnnotatedTypeTree) tree).getUnderlyingType());
        case PARAMETERIZED_TYPE:
            return ((ParameterizedTypeTree) tree).getTypeArguments().isEmpty();
        case NEW_CLASS:
            return isDiamondTree(((NewClassTree) tree).getIdentifier());
        default:
            return false;
    }
}
项目:incubator-netbeans    文件:ExpectedTypeResolver.java   
@Override
public List<? extends TypeMirror> visitAnnotatedType(AnnotatedTypeTree node, Object p) {
    return null;
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
@Override
public Mirror visitAnnotatedType(AnnotatedTypeTree node, EvaluationContext p) {
    // Annotations are ignored and super delegates to the underlying type
    return super.visitAnnotatedType(node, p);
}
项目:oblivion-netbeans-plugin    文件:ApexTreeVisitorAdapter.java   
@Override
public R visitAnnotatedType(AnnotatedTypeTree att, P p) {
    return null;
}
项目:oblivion-netbeans-plugin    文件:TreeFinder.java   
@Override
public List<T> visitAnnotatedType(AnnotatedTypeTree node, T p) {
    return checkForCriteria(node);
}
项目:error-prone    文件:UTemplater.java   
@Override
public UAnnotatedType visitAnnotatedType(AnnotatedTypeTree tree, Void v) {
  return UAnnotatedType.create(
      cast(templateExpressions(tree.getAnnotations()), UAnnotation.class),
      template(tree.getUnderlyingType()));
}
项目:error-prone    文件:UAnnotatedType.java   
@Override
public Choice<Unifier> visitAnnotatedType(AnnotatedTypeTree node, Unifier unifier) {
  return unifyList(unifier, getAnnotations(), node.getAnnotations())
      .thenChoose(unifications(getUnderlyingType(), node.getUnderlyingType()));
}
项目:error-prone    文件:NullablePrimitive.java   
@Override
public Description matchAnnotatedType(AnnotatedTypeTree tree, VisitorState state) {
  Type type = ASTHelpers.getType(tree);
  return check(type, tree.getAnnotations());
}
项目:checker-framework    文件:InternalUtils.java   
public final static List<? extends AnnotationMirror> annotationsFromTree(AnnotatedTypeTree node) {
    return annotationsFromTypeAnnotationTrees(((JCAnnotatedType)node).annotations);
}
项目:checker-framework    文件:CFGBuilder.java   
@Override
public Node visitAnnotatedType(AnnotatedTypeTree tree, Void p) {
    return scan(tree.getUnderlyingType(), p);
}
项目:checker-framework    文件:PurityChecker.java   
@Override
public PurityResult visitAnnotatedType(AnnotatedTypeTree node,
        PurityResult p) {
    assert false : "this type of tree is unexpected here";
    return null;
}
项目:checker-framework    文件:TypeFromTree.java   
@Override
public AnnotatedTypeMirror visitAnnotatedType(AnnotatedTypeTree node,
        AnnotatedTypeFactory f) {
    return f.fromTypeTree(node);
}
项目:bazel    文件:InternalUtils.java   
public static final List<? extends AnnotationMirror> annotationsFromTree(
        AnnotatedTypeTree node) {
    return annotationsFromTypeAnnotationTrees(((JCAnnotatedType) node).annotations);
}
项目:bazel    文件:CFGBuilder.java   
@Override
public Node visitAnnotatedType(AnnotatedTypeTree tree, Void p) {
    return scan(tree.getUnderlyingType(), p);
}
项目:buck    文件:TreePathScannerForTypeResolution.java   
@Override
@Nullable
public final R visitAnnotatedType(AnnotatedTypeTree node, P p) {
  return scan(node.getUnderlyingType(), p);
}
项目:incubator-netbeans    文件:GeneratorUtilities.java   
@Override public Object visitAnnotatedType(AnnotatedTypeTree node, Object p) { return null; }
项目:error-prone    文件:BugChecker.java   
Description matchAnnotatedType(AnnotatedTypeTree tree, VisitorState state);