本文整理汇总了Java中com.sun.source.tree.ThrowTree类的典型用法代码示例。如果您正苦于以下问题:Java ThrowTree类的具体用法?Java ThrowTree怎么用?Java ThrowTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ThrowTree类属于com.sun.source.tree包,在下文中一共展示了ThrowTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Void visitThrow(ThrowTree node, Collection<TreePath> trees) {
if (!analyzeThrows) {
return null;
}
TypeMirror type = info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), node.getExpression()));
boolean isCaught = false;
OUTER: for (Set<TypeMirror> caught : caughtExceptions) {
for (TypeMirror c : caught) {
if (info.getTypes().isSubtype(type, c)) {
isCaught = true;
break OUTER;
}
}
}
super.visitThrow(node, trees);
if (!isCaught) {
trees.add(getCurrentPath());
}
return null;
}
示例2: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Boolean visitThrow(ThrowTree node, Void p) {
TypeMirror type = info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), node.getExpression()));
boolean isCaught = false;
OUTER: for (Pair<Set<TypeMirror>, Tree> pair : caughtExceptions) {
Set<TypeMirror> caught = pair.first();
for (TypeMirror c : caught) {
if (info.getTypes().isSubtype(type, c)) {
isCaught = true;
targetTrees.add(pair.second());
break OUTER;
}
}
}
return super.visitThrow(node, p) == Boolean.TRUE || !isCaught;
}
示例3: isTerminating
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
private boolean isTerminating(StatementTree tree) {
StatementTree first = firstStatement(tree);
if (first instanceof ThrowTree)
return true;
if (first instanceof ReturnTree)
return true;
if (first instanceof IfTree) {
IfTree ifTree = (IfTree)first;
if (ifTree.getElseStatement() != null
&& isTerminating(ifTree.getThenStatement())
&& isTerminating(ifTree.getElseStatement()))
return true;
}
return false;
}
示例4: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Tree visitThrow(ThrowTree tree, Void p) {
ThrowTree n = make.Throw(tree.getExpression());
model.setType(n, model.getType(tree));
comments.copyComments(tree, n);
model.setPos(n, model.getPos(tree));
return n;
}
示例5: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
public Boolean visitThrow(ThrowTree node, TreePath p) {
if (p == null) {
super.visitThrow(node, p);
return false;
}
ThrowTree at = (ThrowTree) p.getLeaf();
return scan(node.getExpression(), at.getExpression(), p);
}
示例6: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Boolean visitThrow(ThrowTree tree, Stack<Tree> d) {
addToExceptionsMap(info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), tree.getExpression())), tree);
super.visitThrow(tree, d);
return Boolean.TRUE;
}
示例7: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Void visitThrow(ThrowTree tree, EnumSet<UseTypes> p) {
if (tree.getExpression() != null && tree.getExpression().getKind() == Kind.IDENTIFIER) {
handlePossibleIdentifier(new TreePath(getCurrentPath(), tree.getExpression()), EnumSet.of(UseTypes.READ));
}
return super.visitThrow(tree, p);
}
示例8: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Void visitThrow(ThrowTree tree, List<Node> d) {
List<Node> below = new ArrayList<Node>();
addCorrespondingType(below);
addCorrespondingComments(below);
super.visitThrow(tree, below);
d.add(new TreeNode(info, getCurrentPath(), below));
return null;
}
示例9: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
public Boolean visitThrow(ThrowTree node, ConstructorData p) {
super.visitThrow(node, p);
if (node.getExpression() != null) {
TypeMirror thrown = info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), node.getExpression()));
recordResumeOnExceptionHandler(thrown);
}
return null;
}
示例10: createRethrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
private static StatementTree createRethrow(WorkingCopy info, TreeMaker make, String name) {
if (!ErrorFixesFakeHint.isRethrow(ErrorFixesFakeHint.getPreferences(info.getFileObject(), FixKind.SURROUND_WITH_TRY_CATCH))) {
return null;
}
ThrowTree result = make.Throw(make.Identifier(name));
info.tag(result.getExpression(), Utilities.TAG_SELECT);
return result;
}
示例11: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public List<Tree> visitThrow(ThrowTree node, ExpressionScanner.ExpressionsInfo p) {
List<Tree> result = null;
if (acceptsTree(node)) {
result = scan(node.getExpression(), p);
}
return result;
}
示例12: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Void visitThrow(ThrowTree node, Void unused) {
sync(node);
token("throw");
builder.space();
scan(node.getExpression(), null);
token(";");
return null;
}
示例13: matches
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public boolean matches(StatementTree expressionTree, VisitorState state) {
if (!(expressionTree instanceof ThrowTree)) {
return false;
}
return thrownMatcher.matches(((ThrowTree) expressionTree).getExpression(), state);
}
示例14: visitThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Void visitThrow(ThrowTree tree, VisitorState visitorState) {
VisitorState state = visitorState.withPath(getCurrentPath());
for (ThrowTreeMatcher matcher : throwMatchers) {
if (!isSuppressed(matcher, state)) {
try {
reportMatch(matcher.matchThrow(tree, state), tree, state);
} catch (Throwable t) {
handleError(matcher, t);
}
}
}
return super.visitThrow(tree, state);
}
示例15: matchThrow
import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Description matchThrow(ThrowTree tree, VisitorState state) {
return (tree.getExpression().getKind() == NULL_LITERAL)
? describeMatch(
tree, SuggestedFix.replace(tree.getExpression(), "new NullPointerException()"))
: NO_MATCH;
}