com.sun.source.tree.AnnotatedTypeTree Java Examples
The following examples show how to use
com.sun.source.tree.AnnotatedTypeTree.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaInputAstVisitor.java From google-java-format with Apache License 2.0 | 6 votes |
@Override public Void visitAnnotatedType(AnnotatedTypeTree node, Void unused) { sync(node); ExpressionTree base = node.getUnderlyingType(); if (base instanceof MemberSelectTree) { MemberSelectTree selectTree = (MemberSelectTree) base; scan(selectTree.getExpression(), null); token("."); visitAnnotations(node.getAnnotations(), BreakOrNot.NO, BreakOrNot.NO); builder.breakToFill(" "); visit(selectTree.getIdentifier()); } else if (base instanceof ArrayTypeTree) { visitAnnotatedArrayType(node); } else { visitAnnotations(node.getAnnotations(), BreakOrNot.NO, BreakOrNot.NO); builder.breakToFill(" "); scan(base, null); } return null; }
Example #2
Source File: DimensionHelpers.java From google-java-format with Apache License 2.0 | 6 votes |
/** * Accumulates a flattened list of array dimensions specifiers with type annotations, and returns * the base type. * * <p>Given {@code int @A @B [][] @C []}, adds {@code [[@A, @B], [@C]]} to dims and returns {@code * int}. */ private static Tree extractDims(Deque<List<AnnotationTree>> dims, Tree node) { switch (node.getKind()) { case ARRAY_TYPE: return extractDims(dims, ((ArrayTypeTree) node).getType()); case ANNOTATED_TYPE: AnnotatedTypeTree annotatedTypeTree = (AnnotatedTypeTree) node; if (annotatedTypeTree.getUnderlyingType().getKind() != Tree.Kind.ARRAY_TYPE) { return node; } node = extractDims(dims, annotatedTypeTree.getUnderlyingType()); dims.addFirst(ImmutableList.copyOf(annotatedTypeTree.getAnnotations())); return node; default: return node; } }
Example #3
Source File: TreeDuplicator.java From netbeans with Apache License 2.0 | 5 votes |
@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; }
Example #4
Source File: TreeNode.java From netbeans with Apache License 2.0 | 5 votes |
@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; }
Example #5
Source File: GenericArrayLocationCriterion.java From annotation-tools with MIT License | 5 votes |
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) ); }
Example #6
Source File: ASTPathCriterion.java From annotation-tools with MIT License | 5 votes |
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; }
Example #7
Source File: Insertions.java From annotation-tools with MIT License | 5 votes |
/** * 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.Kind.PCK) { t = jfa.getExpression(); continue; } } t = ((MemberSelectTree) t).getExpression(); ++result; break; default: break loop; } } return result; }
Example #8
Source File: JavacJ2ObjCIncompatibleStripper.java From j2objc with Apache License 2.0 | 5 votes |
@Override public Void visitAnnotatedType(AnnotatedTypeTree node, Void unused) { if (checkAnnotations(node.getAnnotations(), node)) { super.visitAnnotatedType(node, null); } return null; }
Example #9
Source File: Utilities.java From netbeans with Apache License 2.0 | 4 votes |
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 || "BINDING_PATTERN".equals(leaf.getKind().name())) { 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; }
Example #10
Source File: ExpectedTypeResolver.java From netbeans with Apache License 2.0 | 4 votes |
@Override public List<? extends TypeMirror> visitAnnotatedType(AnnotatedTypeTree node, Object p) { return null; }
Example #11
Source File: TreePathScannerForTypeResolution.java From buck with Apache License 2.0 | 4 votes |
@Override @Nullable public final R visitAnnotatedType(AnnotatedTypeTree node, P p) { return scan(node.getUnderlyingType(), p); }
Example #12
Source File: GeneratorUtilities.java From netbeans with Apache License 2.0 | votes |
@Override public Object visitAnnotatedType(AnnotatedTypeTree node, Object p) { return null; }