本文整理汇总了Java中org.walkmod.javalang.ast.stmt.TryStmt类的典型用法代码示例。如果您正苦于以下问题:Java TryStmt类的具体用法?Java TryStmt怎么用?Java TryStmt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TryStmt类属于org.walkmod.javalang.ast.stmt包,在下文中一共展示了TryStmt类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
public void visit(TryStmt n, A arg) {
List<VariableDeclarationExpr> resources = n.getResources();
if (resources != null) {
for (VariableDeclarationExpr resource : resources) {
resource.accept(this, arg);
}
}
n.getTryBlock().accept(this, arg);
if (n.getCatchs() != null) {
for (CatchClause c : n.getCatchs()) {
c.accept(this, arg);
}
}
if (n.getFinallyBlock() != null) {
n.getFinallyBlock().accept(this, arg);
}
}
示例2: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
public void visit(TryStmt n, VisitorContext ctx) {
Object o = ctx.get(NODE_TO_COMPARE_KEY);
if (o != null && o instanceof TryStmt) {
TryStmt aux = (TryStmt) o;
boolean backup = isUpdated();
setIsUpdated(false);
inferASTChanges(n.getTryBlock(), aux.getTryBlock());
inferASTChanges(n.getCatchs(), aux.getCatchs());
inferASTChanges(n.getFinallyBlock(), aux.getFinallyBlock());
inferASTChanges(n.getResources(), aux.getResources());
if (!isUpdated()) {
increaseUnmodifiedNodes(TryStmt.class);
} else {
applyUpdate(n, aux, n.getResources(), aux.getResources());
increaseUpdatedNodes(TryStmt.class);
}
setIsUpdated(backup || isUpdated());
} else if (o != null) {
setIsUpdated(true);
applyUpdate(n, (Node) o);
}
}
示例3: testMulticatchStatements
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
@Test
public void testMulticatchStatements() throws Exception {
if (SourceVersion.latestSupported().ordinal() >= 8) {
CompilationUnit cu = run("import java.io.*; public class A { "
+ "void test() throws FileNotFoundException, ClassNotFoundException {} "
+ "public void run (){ try{ test(); }catch(FileNotFoundException|ClassNotFoundException e){}}}");
MethodDeclaration md = (MethodDeclaration) cu.getTypes().get(0).getMembers().get(1);
TryStmt stmt = (TryStmt) md.getBody().getStmts().get(0);
SymbolData sd = stmt.getCatchs().get(0).getExcept().getSymbolData();
Assert.assertNotNull(sd);
List<Class<?>> bounds = sd.getBoundClasses();
Assert.assertEquals("java.io.FileNotFoundException", bounds.get(0).getName());
Assert.assertEquals("java.lang.ClassNotFoundException", bounds.get(1).getName());
}
}
示例4: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
public R visit(TryStmt n, A arg) {
n.getTryBlock().accept(this, arg);
if (n.getCatchs() != null) {
for (CatchClause c : n.getCatchs()) {
c.accept(this, arg);
}
}
if (n.getFinallyBlock() != null) {
n.getFinallyBlock().accept(this, arg);
}
return null;
}
示例5: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
public Boolean visit(TryStmt n1, Node arg) {
TryStmt n2 = (TryStmt) arg;
if (!nodeEquals(n1.getTryBlock(), n2.getTryBlock())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getCatchs(), n2.getCatchs())) {
return Boolean.FALSE;
}
if (!nodeEquals(n1.getFinallyBlock(), n2.getFinallyBlock())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例6: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
@Override
public Node visit(TryStmt _n, Object _arg) {
List<VariableDeclarationExpr> resources = visit(_n.getResources(), _arg);
BlockStmt tryBlock = cloneNodes(_n.getTryBlock(), _arg);
List<CatchClause> catchs = visit(_n.getCatchs(), _arg);
BlockStmt finallyBlock = cloneNodes(_n.getFinallyBlock(), _arg);
TryStmt r = new TryStmt(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), resources,
tryBlock, catchs, finallyBlock);
return r;
}
示例7: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
@Override
public void visit(final TryStmt n, final Object arg) {
prepareComments(n);
printPreviousComments(n, arg);
printer.print("try ");
if (n.getResources() != null && !n.getResources().isEmpty()) {
printer.print("(");
Iterator<VariableDeclarationExpr> resources = n.getResources().iterator();
boolean first = true;
while (resources.hasNext()) {
VariableDeclarationExpr next = resources.next();
visit(next, arg);
if (resources.hasNext()) {
printer.print(";");
printer.printLn();
if (first) {
printer.indent();
}
}
first = false;
}
if (n.getResources().size() > 1) {
printer.unindent();
}
printer.print(") ");
}
n.getTryBlock().accept(this, arg);
if (n.getCatchs() != null) {
for (final CatchClause c : n.getCatchs()) {
c.accept(this, arg);
}
}
if (n.getFinallyBlock() != null) {
printer.print(" finally ");
n.getFinallyBlock().accept(this, arg);
}
}
示例8: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
public void visit(TryStmt n, VisitorContext arg) {
if (preVisitor != null) {
preVisitor.visit(n, arg);
}
super.visit(n, arg);
if (postVisitor != null) {
postVisitor.visit(n, arg);
}
}
示例9: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
public Node visit(TryStmt n, A arg) {
n.setTryBlock((BlockStmt) n.getTryBlock().accept(this, arg));
List<CatchClause> catchs = n.getCatchs();
if (catchs != null) {
for (int i = 0; i < catchs.size(); i++) {
catchs.set(i, (CatchClause) catchs.get(i).accept(this, arg));
}
removeNulls(catchs);
}
if (n.getFinallyBlock() != null) {
n.setFinallyBlock((BlockStmt) n.getFinallyBlock().accept(this, arg));
}
return n;
}
示例10: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
@Override
public void visit(TryStmt n, A arg) {
symbolTable.pushScope();
super.visit(n, arg);
symbolTable.popScope();
}
示例11: TryStatement
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
final public TryStmt TryStatement() throws ParseException {
List resources = new LinkedList();
BlockStmt tryBlock;
BlockStmt finallyBlock = null;
List catchs = null;
Parameter except;
BlockStmt catchBlock;
Modifier exceptModifier;
Type exceptType;
List exceptTypes = new LinkedList();
VariableDeclaratorId exceptId;
int line;
int column;
int cLine;
int cColumn;
jj_consume_token(TRY);
line = token.beginLine;
column = token.beginColumn;
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case LPAREN:
resources = ResourceSpecification();
break;
default:
jj_la1[161] = jj_gen;;
}
tryBlock = Block();
label_66: while (true) {
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case CATCH:;
break;
default:
jj_la1[162] = jj_gen;
break label_66;
}
jj_consume_token(CATCH);
cLine = token.beginLine;
cColumn = token.beginColumn;
jj_consume_token(LPAREN);
exceptModifier = Modifiers();
exceptType = Type();
exceptTypes.add(exceptType);
label_67: while (true) {
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case BIT_OR:;
break;
default:
jj_la1[163] = jj_gen;
break label_67;
}
jj_consume_token(BIT_OR);
exceptType = Type();
exceptTypes.add(exceptType);
}
exceptId = VariableDeclaratorId();
jj_consume_token(RPAREN);
catchBlock = Block();
catchs = add(catchs, new CatchClause(cLine, cColumn, token.endLine, token.endColumn,
exceptModifier.modifiers, exceptModifier.annotations, exceptTypes, exceptId, catchBlock));
exceptTypes = new LinkedList();
}
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case FINALLY:
jj_consume_token(FINALLY);
finallyBlock = Block();
break;
default:
jj_la1[164] = jj_gen;;
}
TryStmt tmp =
new TryStmt(line, column, token.endLine, token.endColumn, resources, tryBlock, catchs, finallyBlock);
{
if (true)
return tmp;
}
throw new Error("Missing return statement in function");
}
示例12: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
public R visit(TryStmt n, A arg);
示例13: visit
import org.walkmod.javalang.ast.stmt.TryStmt; //导入依赖的package包/类
public void visit(TryStmt n, A arg);