本文整理汇总了Java中com.sun.source.doctree.ThrowsTree.getExceptionName方法的典型用法代码示例。如果您正苦于以下问题:Java ThrowsTree.getExceptionName方法的具体用法?Java ThrowsTree.getExceptionName怎么用?Java ThrowsTree.getExceptionName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.source.doctree.ThrowsTree
的用法示例。
在下文中一共展示了ThrowsTree.getExceptionName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitThrows
import com.sun.source.doctree.ThrowsTree; //导入方法依赖的package包/类
@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);
}
示例2: visitThrows
import com.sun.source.doctree.ThrowsTree; //导入方法依赖的package包/类
@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);
}
示例3: rewriteChildren
import com.sun.source.doctree.ThrowsTree; //导入方法依赖的package包/类
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;
}
示例4: getException
import com.sun.source.doctree.ThrowsTree; //导入方法依赖的package包/类
public Element getException(BaseConfiguration c, DocTree dtree) {
if (dtree.getKind() == THROWS || dtree.getKind() == EXCEPTION) {
ThrowsTree tt = (ThrowsTree)dtree;
ReferenceTree exceptionName = tt.getExceptionName();
return getElement(c, exceptionName);
}
return null;
}
示例5: getException
import com.sun.source.doctree.ThrowsTree; //导入方法依赖的package包/类
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;
}
示例6: visitThrows
import com.sun.source.doctree.ThrowsTree; //导入方法依赖的package包/类
@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;
}