本文整理汇总了Java中com.sun.source.doctree.ThrowsTree类的典型用法代码示例。如果您正苦于以下问题:Java ThrowsTree类的具体用法?Java ThrowsTree怎么用?Java ThrowsTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ThrowsTree类属于com.sun.source.doctree包,在下文中一共展示了ThrowsTree类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:Checker.java
示例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);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:Checker.java
示例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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ImmutableDocTreeTranslator.java
示例4: visitThrows
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
@Override
public Void visitThrows(ThrowsTree node, Void p) {
printTagName(node);
needSpace();
doAccept((DCTree)node.getExceptionName());
if(!node.getDescription().isEmpty()) {
needSpace();
for (DocTree docTree : node.getDescription()) {
doAccept((DCTree)docTree);
}
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:VeryPretty.java
示例5: checkThrowsDeclared
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
@NbBundle.Messages({"# {0} - [@throws|@exception]", "# {1} - @throws name",
"DUPLICATE_THROWS_DESC=Duplicate @{0} tag: {1}",
"# {0} - [@throws|@exception]", "# {1} - @throws name",
"UNKNOWN_THROWABLE_DESC=Unknown throwable: @{0} {1}"})
private void checkThrowsDeclared(ThrowsTree tree, Element ex, String fqn, List<? extends TypeMirror> list, DocTreePathHandle dtph, int start, int end, List<ErrorDescription> errors) {
boolean found = false;
final TypeMirror type;
if(ex != null) {
type = ex.asType();
} else {
TypeElement typeElement = javac.getElements().getTypeElement(fqn);
if(typeElement != null) {
type = typeElement.asType();
} else {
type = null;
}
}
for (TypeMirror t: list) {
if(ctx.isCanceled()) { return; }
if(type != null && javac.getTypes().isAssignable(type, t)) {
if(!foundThrows.add(type)) {
errors.add(ErrorDescriptionFactory.forSpan(ctx, start, end, DUPLICATE_THROWS_DESC(tree.getTagName(), fqn), new RemoveTagFix(dtph, "@" + tree.getTagName()).toEditorFix()));
}
found = true;
break;
}
if (type == null && fqn.equals(t.toString())) {
if(!foundThrows.add(t)) {
errors.add(ErrorDescriptionFactory.forSpan(ctx, start, end, DUPLICATE_THROWS_DESC(tree.getTagName(), fqn), new RemoveTagFix(dtph, "@" + tree.getTagName()).toEditorFix()));
}
found = true;
break;
}
}
if (!found) {
errors.add(ErrorDescriptionFactory.forSpan(ctx, start, end, UNKNOWN_THROWABLE_DESC(tree.getTagName(), fqn), new RemoveTagFix(dtph, "@" + tree.getTagName()).toEditorFix()));
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:Analyzer.java
示例6: 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;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:CommentHelper.java
示例7: 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;
}
开发者ID:campolake,项目名称:openjdk9,代码行数:9,代码来源:CommentHelper.java
示例8: visitThrows
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
@Override
public DocTree visitThrows(ThrowsTree tree, Object p) {
return rewriteChildren(tree);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ImmutableDocTreeTranslator.java
示例9: Throws
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
public ThrowsTree Throws(ReferenceTree name, List<? extends DocTree> description) {
return docMake.at(NOPOS).newThrowsTree(name, description);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:TreeFactory.java
示例10: Exception
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
public ThrowsTree Exception(ReferenceTree name, List<? extends DocTree> description) {
return docMake.at(NOPOS).newExceptionTree(name, description);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:TreeFactory.java
示例11: visitThrows
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
/**
* @since 1.47
*/
@Override
public DocTree visitThrows(ThrowsTree node, Element p) {
return docScanner.visitThrows(node, p, null);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:RefactoringVisitor.java
示例12: 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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:57,代码来源:Analyzer.java
示例13: getThrownException
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
private String getThrownException(JavacTask task, TreePath rootOn, DocCommentTree comment, ThrowsTree tt) {
DocTrees trees = DocTrees.instance(task);
Element exc = trees.getElement(new DocTreePath(new DocTreePath(rootOn, comment), tt.getExceptionName()));
return exc != null ? exc.toString() : null;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:JavadocHelper.java
示例14: visitThrows
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public Object visitThrows(ThrowsTree node, Object p) {
return formatDef(node.getExceptionName().getSignature(), node.getDescription());
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:JavadocFormatter.java
示例15: getExceptionName
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
public ReferenceTree getExceptionName(DocTree dtree) {
return (dtree.getKind() == THROWS || dtree.getKind() == EXCEPTION)
? ((ThrowsTree)dtree).getExceptionName()
: null;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:CommentHelper.java
示例16: Throws
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
/**Creates the DocTree's ThrowsTree that will produce @throws.
*
* @param name reference to the documented exception
* @param description the description of the thrown exception
* @return newly created ThrowsTree
* @since 0.124
*/
public ThrowsTree Throws(ReferenceTree name, List<? extends DocTree> description) {
return delegate.Throws(name, description);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:TreeMaker.java
示例17: Exception
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
/**Creates the DocTree's ThrowsTree that will produce @exception.
*
* @param name reference to the documented exception
* @param description the description of the thrown exception
* @return newly created Exception
* @since 0.124
*/
public ThrowsTree Exception(ReferenceTree name, List<? extends DocTree> description) {
return delegate.Exception(name, description);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:TreeMaker.java
示例18: newExceptionTree
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
/**
* Create a new {@code ExceptionTree} object, to represent an {@code @exception } tag.
* @param name the name of the exception
* @param description a description of why the exception might be thrown
* @return an {@code ExceptionTree} object
*/
ThrowsTree newExceptionTree(ReferenceTree name, List<? extends DocTree> description);
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:DocTreeFactory.java
示例19: newThrowsTree
import com.sun.source.doctree.ThrowsTree; //导入依赖的package包/类
/**
* Create a new {@code ThrowsTree} object, to represent a {@code @throws } tag.
* @param name the name of the exception
* @param description a description of why the exception might be thrown
* @return a {@code ThrowsTree} object
*/
ThrowsTree newThrowsTree(ReferenceTree name, List<? extends DocTree> description);
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:DocTreeFactory.java
注:本文中的com.sun.source.doctree.ThrowsTree类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论