Java Code Examples for com.sun.source.doctree.ThrowsTree#getExceptionName()
The following examples show how to use
com.sun.source.doctree.ThrowsTree#getExceptionName() .
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: Checker.java From TencentKona-8 with 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 File: Checker.java From jdk8u60 with 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 3
Source File: Checker.java From openjdk-jdk8u with 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 4
Source File: Checker.java From openjdk-jdk8u-backup with 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 File: Checker.java From openjdk-jdk9 with 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 6
Source File: Checker.java From hottub with 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 File: Checker.java From openjdk-8-source with 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 8
Source File: Checker.java From openjdk-8 with 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 9
Source File: ImmutableDocTreeTranslator.java From netbeans with Apache License 2.0 | 5 votes |
protected final ThrowsTree rewriteChildren(ThrowsTree tree) { ThrowsTree value = tree; ReferenceTree exception = (ReferenceTree) translate(tree.getExceptionName()); List<? extends DocTree> description = translateDoc(tree.getDescription()); if (exception != tree.getExceptionName() || description != tree.getDescription()) { value = make.Throws(exception, description); } return value; }
Example 10
Source File: CommentHelper.java From openjdk-jdk9 with 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; }
Example 11
Source File: Analyzer.java From netbeans with Apache License 2.0 | 4 votes |
@Override public Void visitThrows(ThrowsTree tree, List<ErrorDescription> errors) { boolean oldInheritDoc = foundInheritDoc; ReferenceTree exName = tree.getExceptionName(); DocTreePath refPath = new DocTreePath(getCurrentPath(), tree.getExceptionName()); Element ex = javac.getDocTrees().getElement(refPath); Types types = javac.getTypes(); Elements elements = javac.getElements(); final TypeElement throwableEl = elements.getTypeElement("java.lang.Throwable"); final TypeElement errorEl = elements.getTypeElement("java.lang.Error"); final TypeElement runtimeEl = elements.getTypeElement("java.lang.RuntimeException"); if(throwableEl == null || errorEl == null || runtimeEl == null) { LOG.warning("Broken java-platform, cannot resolve " + throwableEl == null? "java.lang.Throwable" : errorEl == null? "java.lang.Error" : "java.lang.RuntimeException"); //NOI18N return null; } TypeMirror throwable = throwableEl.asType(); TypeMirror error = errorEl.asType(); TypeMirror runtime = runtimeEl.asType(); DocTreePath currentDocPath = getCurrentPath(); DocTreePathHandle dtph = DocTreePathHandle.create(currentDocPath, javac); if(dtph == null) { return null; } DocSourcePositions sp = (DocSourcePositions) javac.getTrees().getSourcePositions(); int start = (int) sp.getStartPosition(javac.getCompilationUnit(), currentDocPath.getDocComment(), tree); int end = (int) sp.getEndPosition(javac.getCompilationUnit(), currentDocPath.getDocComment(), tree); if (ex == null || (ex.asType().getKind() == TypeKind.DECLARED && types.isAssignable(ex.asType(), throwable))) { switch (currentElement.getKind()) { case CONSTRUCTOR: case METHOD: if (ex == null || !(types.isAssignable(ex.asType(), error) || types.isAssignable(ex.asType(), runtime))) { ExecutableElement ee = (ExecutableElement) currentElement; String fqn; if (ex != null) { fqn = ((TypeElement) ex).getQualifiedName().toString(); } else { ExpressionTree referenceClass = javac.getTreeUtilities().getReferenceClass(new DocTreePath(currentDocPath, exName)); if(referenceClass == null) break; fqn = referenceClass.toString(); } checkThrowsDeclared(tree, ex, fqn, ee.getThrownTypes(), dtph, start, end, errors); } break; default: // env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } } else { // env.messages.error(REFERENCE, tree, "dc.invalid.throws"); } warnIfEmpty(tree, tree.getDescription()); super.visitThrows(tree, errors); foundInheritDoc = oldInheritDoc; return null; }