com.sun.source.doctree.ReferenceTree Java Examples
The following examples show how to use
com.sun.source.doctree.ReferenceTree.
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 Project: TencentKona-8 Author: Tencent File: Checker.java License: GNU General Public License v2.0 | 6 votes |
@Override public Void visitThrows(ThrowsTree tree, Void ignore) { ReferenceTree exName = tree.getExceptionName(); Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName)); if (ex == null) { env.messages.error(REFERENCE, tree, "dc.ref.not.found"); } else if (isThrowable(ex.asType())) { switch (env.currElement.getKind()) { case CONSTRUCTOR: case METHOD: if (isCheckedException(ex.asType())) { ExecutableElement ee = (ExecutableElement) env.currElement; checkThrowsDeclared(exName, ex.asType(), ee.getThrownTypes()); } break; default: env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } } else { env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } warnIfEmpty(tree, tree.getDescription()); return scan(tree.getDescription(), ignore); }
Example #2
Source Project: openjdk-8 Author: bpupadhyaya File: ReferenceTest.java License: GNU General Public License v2.0 | 6 votes |
void checkReference(ReferenceTree tree, List<? extends DocTree> label) { String sig = tree.getSignature(); Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree)); if (found == null) { System.err.println(sig + " NOT FOUND"); } else { System.err.println(sig + " found " + found.getKind() + " " + found); } String expect = "UNKNOWN"; if (label.size() > 0 && label.get(0) instanceof TextTree) expect = ((TextTree) label.get(0)).getBody(); if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { error(tree, "Unexpected value found: " + found +", expected: " + expect); } }
Example #3
Source Project: TencentKona-8 Author: Tencent File: ReferenceTest.java License: GNU General Public License v2.0 | 6 votes |
void checkReference(ReferenceTree tree, List<? extends DocTree> label) { String sig = tree.getSignature(); Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree)); if (found == null) { System.err.println(sig + " NOT FOUND"); } else { System.err.println(sig + " found " + found.getKind() + " " + found); } String expect = "UNKNOWN"; if (label.size() > 0 && label.get(0) instanceof TextTree) expect = ((TextTree) label.get(0)).getBody(); if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { error(tree, "Unexpected value found: " + found +", expected: " + expect); } }
Example #4
Source Project: openjdk-8 Author: bpupadhyaya File: Checker.java License: GNU General Public License v2.0 | 6 votes |
@Override public Void visitThrows(ThrowsTree tree, Void ignore) { ReferenceTree exName = tree.getExceptionName(); Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName)); if (ex == null) { env.messages.error(REFERENCE, tree, "dc.ref.not.found"); } else if (isThrowable(ex.asType())) { switch (env.currElement.getKind()) { case CONSTRUCTOR: case METHOD: if (isCheckedException(ex.asType())) { ExecutableElement ee = (ExecutableElement) env.currElement; checkThrowsDeclared(exName, ex.asType(), ee.getThrownTypes()); } break; default: env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } } else { env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } warnIfEmpty(tree, tree.getDescription()); return scan(tree.getDescription(), ignore); }
Example #5
Source Project: jdk8u60 Author: chenghanpeng File: ReferenceTest.java License: GNU General Public License v2.0 | 6 votes |
void checkReference(ReferenceTree tree, List<? extends DocTree> label) { String sig = tree.getSignature(); Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree)); if (found == null) { System.err.println(sig + " NOT FOUND"); } else { System.err.println(sig + " found " + found.getKind() + " " + found); } String expect = "UNKNOWN"; if (label.size() > 0 && label.get(0) instanceof TextTree) expect = ((TextTree) label.get(0)).getBody(); if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { error(tree, "Unexpected value found: " + found +", expected: " + expect); } }
Example #6
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 6 votes |
@Override public Void visitThrows(ThrowsTree tree, Void ignore) { ReferenceTree exName = tree.getExceptionName(); Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName)); if (ex == null) { env.messages.error(REFERENCE, tree, "dc.ref.not.found"); } else if (isThrowable(ex.asType())) { switch (env.currElement.getKind()) { case CONSTRUCTOR: case METHOD: if (isCheckedException(ex.asType())) { ExecutableElement ee = (ExecutableElement) env.currElement; checkThrowsDeclared(exName, ex.asType(), ee.getThrownTypes()); } break; default: env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } } else { env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } warnIfEmpty(tree, tree.getDescription()); return scan(tree.getDescription(), ignore); }
Example #7
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: ReferenceTest.java License: GNU General Public License v2.0 | 6 votes |
void checkReference(ReferenceTree tree, List<? extends DocTree> label) { String sig = tree.getSignature(); Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree)); if (found == null) { System.err.println(sig + " NOT FOUND"); } else { System.err.println(sig + " found " + found.getKind() + " " + found); } String expect = "UNKNOWN"; if (label.size() > 0 && label.get(0) instanceof TextTree) expect = ((TextTree) label.get(0)).getBody(); if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { error(tree, "Unexpected value found: " + found +", expected: " + expect); } }
Example #8
Source Project: netbeans Author: apache File: VeryPretty.java License: 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 #9
Source Project: openjdk-8-source Author: keerath File: ReferenceTest.java License: GNU General Public License v2.0 | 6 votes |
void checkReference(ReferenceTree tree, List<? extends DocTree> label) { String sig = tree.getSignature(); Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree)); if (found == null) { System.err.println(sig + " NOT FOUND"); } else { System.err.println(sig + " found " + found.getKind() + " " + found); } String expect = "UNKNOWN"; if (label.size() > 0 && label.get(0) instanceof TextTree) expect = ((TextTree) label.get(0)).getBody(); if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { error(tree, "Unexpected value found: " + found +", expected: " + expect); } }
Example #10
Source Project: hottub Author: dsrg-uoft File: ReferenceTest.java License: GNU General Public License v2.0 | 6 votes |
void checkReference(ReferenceTree tree, List<? extends DocTree> label) { String sig = tree.getSignature(); Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree)); if (found == null) { System.err.println(sig + " NOT FOUND"); } else { System.err.println(sig + " found " + found.getKind() + " " + found); } String expect = "UNKNOWN"; if (label.size() > 0 && label.get(0) instanceof TextTree) expect = ((TextTree) label.get(0)).getBody(); if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { error(tree, "Unexpected value found: " + found +", expected: " + expect); } }
Example #11
Source Project: google-java-format Author: google File: RemoveUnusedImports.java License: 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 #12
Source Project: openjdk-8-source Author: keerath File: Checker.java License: GNU General Public License v2.0 | 6 votes |
@Override public Void visitThrows(ThrowsTree tree, Void ignore) { ReferenceTree exName = tree.getExceptionName(); Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName)); if (ex == null) { env.messages.error(REFERENCE, tree, "dc.ref.not.found"); } else if (isThrowable(ex.asType())) { switch (env.currElement.getKind()) { case CONSTRUCTOR: case METHOD: if (isCheckedException(ex.asType())) { ExecutableElement ee = (ExecutableElement) env.currElement; checkThrowsDeclared(exName, ex.asType(), ee.getThrownTypes()); } break; default: env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } } else { env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } warnIfEmpty(tree, tree.getDescription()); return scan(tree.getDescription(), ignore); }
Example #13
Source Project: netbeans Author: apache File: FindLocalUsagesQuery.java License: Apache License 2.0 | 6 votes |
@Override public DocTree visitReference(ReferenceTree node, Element p) { DocTrees trees = info.getDocTrees(); Element el = trees.getElement(getCurrentPath()); if (el != null && el.equals(toFind)) { int[] span = treeUtils.findNameSpan(getCurrentPath().getDocComment(), node); if(span != null) { try { MutablePositionRegion region = createRegion(doc, span[0], span[1]); usages.add(region); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } } } return super.visitReference(node, p); }
Example #14
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 6 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public Void visitThrows(ThrowsTree tree, Void ignore) { ReferenceTree exName = tree.getExceptionName(); Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName)); if (ex == null) { env.messages.error(REFERENCE, tree, "dc.ref.not.found"); } else if (isThrowable(ex.asType())) { switch (env.currElement.getKind()) { case CONSTRUCTOR: case METHOD: if (isCheckedException(ex.asType())) { ExecutableElement ee = (ExecutableElement) env.currElement; checkThrowsDeclared(exName, ex.asType(), ee.getThrownTypes()); } break; default: env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } } else { env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } warnIfEmpty(tree, tree.getDescription()); return scan(tree.getDescription(), ignore); }
Example #15
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 6 votes |
@Override public Void visitThrows(ThrowsTree tree, Void ignore) { ReferenceTree exName = tree.getExceptionName(); Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName)); if (ex == null) { env.messages.error(REFERENCE, tree, "dc.ref.not.found"); } else if (isThrowable(ex.asType())) { switch (env.currElement.getKind()) { case CONSTRUCTOR: case METHOD: if (isCheckedException(ex.asType())) { ExecutableElement ee = (ExecutableElement) env.currElement; checkThrowsDeclared(exName, ex.asType(), ee.getThrownTypes()); } break; default: env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } } else { env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } warnIfEmpty(tree, tree.getDescription()); return scan(tree.getDescription(), ignore); }
Example #16
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: ReferenceTest.java License: GNU General Public License v2.0 | 6 votes |
void checkReference(ReferenceTree tree, List<? extends DocTree> label) { String sig = tree.getSignature(); Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree)); if (found == null) { System.err.println(sig + " NOT FOUND"); } else { System.err.println(sig + " found " + found.getKind() + " " + found); } String expect = "UNKNOWN"; if (label.size() > 0 && label.get(0) instanceof TextTree) expect = ((TextTree) label.get(0)).getBody(); if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { error(tree, "Unexpected value found: " + found +", expected: " + expect); } }
Example #17
Source Project: TencentKona-8 Author: Tencent File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override public Void visitReference(ReferenceTree tree, Void ignore) { String sig = tree.getSignature(); if (sig.contains("<") || sig.contains(">")) env.messages.error(REFERENCE, tree, "dc.type.arg.not.allowed"); Element e = env.trees.getElement(getCurrentPath()); if (e == null) env.messages.error(REFERENCE, tree, "dc.ref.not.found"); return super.visitReference(tree, ignore); }
Example #18
Source Project: TencentKona-8 Author: Tencent File: Checker.java License: GNU General Public License v2.0 | 5 votes |
private void checkThrowsDeclared(ReferenceTree tree, TypeMirror t, List<? extends TypeMirror> list) { boolean found = false; for (TypeMirror tl : list) { if (env.types.isAssignable(t, tl)) { foundThrows.add(tl); found = true; } } if (!found) env.messages.error(REFERENCE, tree, "dc.exception.not.thrown", t); }
Example #19
Source Project: TencentKona-8 Author: Tencent File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override public Void visitValue(ValueTree tree, Void ignore) { ReferenceTree ref = tree.getReference(); if (ref == null || ref.getSignature().isEmpty()) { if (!isConstant(env.currElement)) env.messages.error(REFERENCE, tree, "dc.value.not.allowed.here"); } else { Element e = env.trees.getElement(new DocTreePath(getCurrentPath(), ref)); if (!isConstant(e)) env.messages.error(REFERENCE, tree, "dc.value.not.a.constant"); } markEnclosingTag(Flag.HAS_INLINE_TAG); return super.visitValue(tree, ignore); }
Example #20
Source Project: jdk8u60 Author: chenghanpeng File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override public Void visitReference(ReferenceTree tree, Void ignore) { String sig = tree.getSignature(); if (sig.contains("<") || sig.contains(">")) env.messages.error(REFERENCE, tree, "dc.type.arg.not.allowed"); Element e = env.trees.getElement(getCurrentPath()); if (e == null) env.messages.error(REFERENCE, tree, "dc.ref.not.found"); return super.visitReference(tree, ignore); }
Example #21
Source Project: jdk8u60 Author: chenghanpeng File: Checker.java License: GNU General Public License v2.0 | 5 votes |
private void checkThrowsDeclared(ReferenceTree tree, TypeMirror t, List<? extends TypeMirror> list) { boolean found = false; for (TypeMirror tl : list) { if (env.types.isAssignable(t, tl)) { foundThrows.add(tl); found = true; } } if (!found) env.messages.error(REFERENCE, tree, "dc.exception.not.thrown", t); }
Example #22
Source Project: jdk8u60 Author: chenghanpeng File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override public Void visitValue(ValueTree tree, Void ignore) { ReferenceTree ref = tree.getReference(); if (ref == null || ref.getSignature().isEmpty()) { if (!isConstant(env.currElement)) env.messages.error(REFERENCE, tree, "dc.value.not.allowed.here"); } else { Element e = env.trees.getElement(new DocTreePath(getCurrentPath(), ref)); if (!isConstant(e)) env.messages.error(REFERENCE, tree, "dc.value.not.a.constant"); } markEnclosingTag(Flag.HAS_INLINE_TAG); return super.visitValue(tree, ignore); }
Example #23
Source Project: hottub Author: dsrg-uoft File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override public Void visitValue(ValueTree tree, Void ignore) { ReferenceTree ref = tree.getReference(); if (ref == null || ref.getSignature().isEmpty()) { if (!isConstant(env.currElement)) env.messages.error(REFERENCE, tree, "dc.value.not.allowed.here"); } else { Element e = env.trees.getElement(new DocTreePath(getCurrentPath(), ref)); if (!isConstant(e)) env.messages.error(REFERENCE, tree, "dc.value.not.a.constant"); } markEnclosingTag(Flag.HAS_INLINE_TAG); return super.visitValue(tree, ignore); }
Example #24
Source Project: openjdk-8-source Author: keerath File: Checker.java License: GNU General Public License v2.0 | 5 votes |
private void checkThrowsDeclared(ReferenceTree tree, TypeMirror t, List<? extends TypeMirror> list) { boolean found = false; for (TypeMirror tl : list) { if (env.types.isAssignable(t, tl)) { foundThrows.add(tl); found = true; } } if (!found) env.messages.error(REFERENCE, tree, "dc.exception.not.thrown", t); }
Example #25
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 5 votes |
private void checkThrowsDeclared(ReferenceTree tree, TypeMirror t, List<? extends TypeMirror> list) { boolean found = false; for (TypeMirror tl : list) { if (env.types.isAssignable(t, tl)) { foundThrows.add(tl); found = true; } } if (!found) env.messages.error(REFERENCE, tree, "dc.exception.not.thrown", t); }
Example #26
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override public Void visitValue(ValueTree tree, Void ignore) { ReferenceTree ref = tree.getReference(); if (ref == null || ref.getSignature().isEmpty()) { if (!isConstant(env.currElement)) env.messages.error(REFERENCE, tree, "dc.value.not.allowed.here"); } else { Element e = env.trees.getElement(new DocTreePath(getCurrentPath(), ref)); if (!isConstant(e)) env.messages.error(REFERENCE, tree, "dc.value.not.a.constant"); } markEnclosingTag(Flag.HAS_INLINE_TAG); return super.visitValue(tree, ignore); }
Example #27
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: ReferenceTest.java License: GNU General Public License v2.0 | 5 votes |
@Override public Void visitSee(SeeTree tree, Void ignore) { List<? extends DocTree> refLabel = tree.getReference(); if (refLabel.size() > 1 && (refLabel.get(0) instanceof ReferenceTree)) { ReferenceTree ref = (ReferenceTree) refLabel.get(0); List<? extends DocTree> label = refLabel.subList(1, refLabel.size()); checkReference(ref, label); } return null; }
Example #28
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public Void visitUses(UsesTree tree, Void ignore) { Element e = env.trees.getElement(env.currPath); if (e.getKind() != ElementKind.MODULE) { env.messages.error(REFERENCE, tree, "dc.invalid.uses"); } ReferenceTree serviceType = tree.getServiceType(); Element se = env.trees.getElement(new DocTreePath(getCurrentPath(), serviceType)); if (se == null) { env.messages.error(REFERENCE, tree, "dc.service.not.found"); } return super.visitUses(tree, ignore); }
Example #29
Source Project: hottub Author: dsrg-uoft File: Checker.java License: GNU General Public License v2.0 | 5 votes |
@Override public Void visitReference(ReferenceTree tree, Void ignore) { String sig = tree.getSignature(); if (sig.contains("<") || sig.contains(">")) env.messages.error(REFERENCE, tree, "dc.type.arg.not.allowed"); Element e = env.trees.getElement(getCurrentPath()); if (e == null) env.messages.error(REFERENCE, tree, "dc.ref.not.found"); return super.visitReference(tree, ignore); }
Example #30
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: CommentHelper.java License: GNU General Public License v2.0 | 5 votes |
public Element getException(Configuration c, DocTree dtree) { if (dtree.getKind() == THROWS || dtree.getKind() == EXCEPTION) { ThrowsTree tt = (ThrowsTree)dtree; ReferenceTree exceptionName = tt.getExceptionName(); return getElement(c, exceptionName); } return null; }