com.sun.tools.javac.tree.DCTree.DCReference Java Examples
The following examples show how to use
com.sun.tools.javac.tree.DCTree.DCReference.
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: RemoveUnusedImports.java From google-java-format with Apache License 2.0 | 6 votes |
@Override public Void visitReference(ReferenceTree referenceTree, Void unused) { DCReference reference = (DCReference) referenceTree; long basePos = reference.getSourcePosition((DCTree.DCDocComment) getCurrentPath().getDocComment()); // the position of trees inside the reference node aren't stored, but the qualifier's // start position is the beginning of the reference node if (reference.qualifierExpression != null) { new ReferenceScanner(basePos).scan(reference.qualifierExpression, null); } // Record uses inside method parameters. The javadoc tool doesn't use these, but // IntelliJ does. if (reference.paramTypes != null) { for (JCTree param : reference.paramTypes) { // TODO(cushon): get start positions for the parameters new ReferenceScanner(-1).scan(param, null); } } return null; }
Example #2
Source File: VeryPretty.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Void visitReference(ReferenceTree node, Void p) { //TODO: should use formatting settings: DCReference refNode = (DCReference) node; if (refNode.qualifierExpression != null) { print(refNode.qualifierExpression); } if (refNode.memberName != null) { print("#"); print(refNode.memberName); } if (refNode.paramTypes != null) { print("("); boolean first = true; for (Tree param : refNode.paramTypes) { if (!first) print(", "); print(param.toString()); first = false; } print(")"); } return null; }
Example #3
Source File: JavacTrees.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public Element getElement(DocTreePath path) { DocTree forTree = path.getLeaf(); if (forTree instanceof DCReference) return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); if (forTree instanceof DCIdentifier) { if (path.getParentPath().getLeaf() instanceof DCParam) { return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); } } return null; }
Example #4
Source File: JavacTrees.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public Element getElement(DocTreePath path) { DocTree forTree = path.getLeaf(); if (forTree instanceof DCReference) return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); if (forTree instanceof DCIdentifier) { if (path.getParentPath().getLeaf() instanceof DCParam) { return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); } } return null; }
Example #5
Source File: JavacTrees.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public Element getElement(DocTreePath path) { DocTree forTree = path.getLeaf(); if (forTree instanceof DCReference) return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); if (forTree instanceof DCIdentifier) { if (path.getParentPath().getLeaf() instanceof DCParam) { return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); } } return null; }
Example #6
Source File: JavacTrees.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public Element getElement(DocTreePath path) { DocTree forTree = path.getLeaf(); if (forTree instanceof DCReference) return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); if (forTree instanceof DCIdentifier) { if (path.getParentPath().getLeaf() instanceof DCParam) { return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); } } return null; }
Example #7
Source File: JavacTrees.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public Element getElement(DocTreePath path) { DocTree forTree = path.getLeaf(); if (forTree instanceof DCReference) return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); if (forTree instanceof DCIdentifier) { if (path.getParentPath().getLeaf() instanceof DCParam) { return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); } } return null; }
Example #8
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCValue newValueTree(ReferenceTree ref) { // TODO: verify the reference is to a constant value DCValue tree = new DCValue((DCReference) ref); tree.pos = pos; return tree; }
Example #9
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCThrows newThrowsTree(ReferenceTree name, List<? extends DocTree> description) { // TODO: verify the reference is just to a type (not a field or method) DCThrows tree = new DCThrows(Kind.THROWS, (DCReference) name, cast(description)); tree.pos = pos; return tree; }
Example #10
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCReference newReferenceTree(String signature) { try { ReferenceParser.Reference ref = referenceParser.parse(signature); DCReference tree = new DCReference(signature, ref.qualExpr, ref.member, ref.paramTypes); tree.pos = pos; return tree; } catch (ReferenceParser.ParseException e) { throw new IllegalArgumentException("invalid signature", e); } }
Example #11
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCThrows newExceptionTree(ReferenceTree name, List<? extends DocTree> description) { // TODO: verify the reference is just to a type (not a field or method) DCThrows tree = new DCThrows(Kind.EXCEPTION, (DCReference) name, cast(description)); tree.pos = pos; return tree; }
Example #12
Source File: JavacTrees.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public Element getElement(DocTreePath path) { DocTree forTree = path.getLeaf(); if (forTree instanceof DCReference) return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); if (forTree instanceof DCIdentifier) { if (path.getParentPath().getLeaf() instanceof DCParam) { return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); } } return null; }
Example #13
Source File: TreeUtilities.java From netbeans with Apache License 2.0 | 5 votes |
/**Find the parameters that are specified in the given {@link ReferenceTree}. * * @param path the leaf must be {@link ReferenceTree} * @return the parameters for the referred method, or {@code null} if none. * @since 0.124 */ public @CheckForNull List<? extends Tree> getReferenceParameters(@NonNull DocTreePath path) { TreePath tp = path.getTreePath(); DCReference ref = (DCReference) path.getLeaf(); ((DocTrees) this.info.getTrees()).getElement(path); // was: // ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref); return ref.paramTypes; }
Example #14
Source File: TreeUtilities.java From netbeans with Apache License 2.0 | 5 votes |
/**Find the type (the part before {@code #}) that is being referenced by the given {@link ReferenceTree}. * * @param path the leaf must be {@link ReferenceTree} * @return the referred type, or {@code null} if none. * @since 0.124 */ public @CheckForNull ExpressionTree getReferenceClass(@NonNull DocTreePath path) { TreePath tp = path.getTreePath(); DCReference ref = (DCReference) path.getLeaf(); ((DocTrees) this.info.getTrees()).getElement(path); // was: // ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref); return (ExpressionTree) ref.qualifierExpression; }
Example #15
Source File: TreeUtilities.java From netbeans with Apache License 2.0 | 5 votes |
/**Find span of the name in the DocTree's reference tree (see {@link #getReferenceName(com.sun.source.util.DocTreePath)} * identifier in the source. Returns starting and ending offset of the name in * the source code that was parsed (ie. {@link CompilationInfo.getText()}, which * may differ from the positions in the source document if it has been already * altered. * * @param ref reference for which the identifier should be found * @return the span of the name, or null if cannot be found * @since 0.124 */ public int[] findNameSpan(DocCommentTree docTree, ReferenceTree ref) { Name name = ((DCReference) ref).memberName; if (name == null || !SourceVersion.isIdentifier(name)) { //names like "<error>", etc. return null; } int pos = (int) info.getDocTrees().getSourcePositions().getStartPosition(info.getCompilationUnit(), docTree, ref); if (pos < 0) return null; TokenSequence<JavaTokenId> tokenSequence = info.getTokenHierarchy().tokenSequence(JavaTokenId.language()); tokenSequence.move(pos); if (!tokenSequence.moveNext() || tokenSequence.token().id() != JavaTokenId.JAVADOC_COMMENT) return null; TokenSequence<JavadocTokenId> jdocTS = tokenSequence.embedded(JavadocTokenId.language()); jdocTS.move(pos); boolean wasNext; while ((wasNext = jdocTS.moveNext()) && jdocTS.token().id() != JavadocTokenId.HASH) ; if (wasNext && jdocTS.moveNext()) { if (jdocTS.token().id() == JavadocTokenId.IDENT && name.contentEquals(jdocTS.token().text())) { return new int[] { jdocTS.offset(), jdocTS.offset() + jdocTS.token().length() }; } } return null; }
Example #16
Source File: JavacTrees.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public Element getElement(DocTreePath path) { DocTree forTree = path.getLeaf(); if (forTree instanceof DCReference) return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); if (forTree instanceof DCIdentifier) { if (path.getParentPath().getLeaf() instanceof DCParam) { return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); } } return null; }
Example #17
Source File: JavacTrees.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public Element getElement(DocTreePath path) { DocTree forTree = path.getLeaf(); if (forTree instanceof DCReference) return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); if (forTree instanceof DCIdentifier) { if (path.getParentPath().getLeaf() instanceof DCParam) { return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); } } return null; }
Example #18
Source File: JavacTrees.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public Element getElement(DocTreePath path) { DocTree forTree = path.getLeaf(); if (forTree instanceof DCReference) return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); if (forTree instanceof DCIdentifier) { if (path.getParentPath().getLeaf() instanceof DCParam) { return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); } } return null; }
Example #19
Source File: DocTreeMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCThrows newExceptionTree(ReferenceTree name, List<? extends DocTree> description) { // TODO: verify the reference is just to a type (not a field or method) DCThrows tree = new DCThrows(Kind.EXCEPTION, (DCReference) name, cast(description)); tree.pos = pos; return tree; }
Example #20
Source File: DocTreeMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCReference newReferenceTree(String signature) { try { ReferenceParser.Reference ref = referenceParser.parse(signature); DCReference tree = new DCReference(signature, ref.qualExpr, ref.member, ref.paramTypes); tree.pos = pos; return tree; } catch (ReferenceParser.ParseException e) { throw new IllegalArgumentException("invalid signature", e); } }
Example #21
Source File: DocTreeMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCThrows newThrowsTree(ReferenceTree name, List<? extends DocTree> description) { // TODO: verify the reference is just to a type (not a field or method) DCThrows tree = new DCThrows(Kind.THROWS, (DCReference) name, cast(description)); tree.pos = pos; return tree; }
Example #22
Source File: DocTreeMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCValue newValueTree(ReferenceTree ref) { // TODO: verify the reference is to a constant value DCValue tree = new DCValue((DCReference) ref); tree.pos = pos; return tree; }
Example #23
Source File: ImmutableDocTreeTranslator.java From netbeans with Apache License 2.0 | 5 votes |
protected final ReferenceTree rewriteChildren(ReferenceTree tree) { DCReference refTree = (DCReference) tree; ReferenceTree value = tree; ExpressionTree classReference = (ExpressionTree) translate(refTree.qualifierExpression); List<? extends Tree> methodParameters = translate(refTree.paramTypes); if(classReference != refTree.qualifierExpression || methodParameters != refTree.paramTypes) { value = make.Reference(classReference, refTree.memberName, methodParameters); } return value; }
Example #24
Source File: DocTreeMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCSerialField newSerialFieldTree(IdentifierTree name, ReferenceTree type, List<? extends DocTree> description) { DCSerialField tree = new DCSerialField((DCIdentifier) name, (DCReference) type, cast(description)); tree.pos = pos; return tree; }
Example #25
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCLink newLinkTree(ReferenceTree ref, List<? extends DocTree> label) { DCLink tree = new DCLink(Kind.LINK, (DCReference) ref, cast(label)); tree.pos = pos; return tree; }
Example #26
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCLink newLinkPlainTree(ReferenceTree ref, List<? extends DocTree> label) { DCLink tree = new DCLink(Kind.LINK_PLAIN, (DCReference) ref, cast(label)); tree.pos = pos; return tree; }
Example #27
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCProvides newProvidesTree(ReferenceTree name, List<? extends DocTree> description) { DCProvides tree = new DCProvides((DCReference) name, cast(description)); tree.pos = pos; return tree; }
Example #28
Source File: DocTreeMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public DCReference newReferenceTree(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) { DCReference tree = new DCReference(signature, qualExpr, member, paramTypes); tree.pos = pos; return tree; }
Example #29
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public DCReference newReferenceTree(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) { DCReference tree = new DCReference(signature, qualExpr, member, paramTypes); tree.pos = pos; return tree; }
Example #30
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DCSerialField newSerialFieldTree(IdentifierTree name, ReferenceTree type, List<? extends DocTree> description) { DCSerialField tree = new DCSerialField((DCIdentifier) name, (DCReference) type, cast(description)); tree.pos = pos; return tree; }