當前位置: 首頁>>代碼示例>>Java>>正文


Java TryStmt類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:18,代碼來源:VoidVisitorAdapter.java

示例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);
    }
}
 
開發者ID:walkmod,項目名稱:walkmod-javalang-plugin,代碼行數:23,代碼來源:ChangeLogVisitor.java

示例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());
    }
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:16,代碼來源:SymbolVisitorAdapterTest.java

示例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;
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:13,代碼來源:GenericVisitorAdapter.java

示例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;
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:14,代碼來源:EqualsVisitor.java

示例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;
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:11,代碼來源:CloneVisitor.java

示例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);
    }
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:38,代碼來源:DumpVisitor.java

示例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);
    }
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:10,代碼來源:CompositeVisitor.java

示例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;
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:15,代碼來源:ModifierVisitorAdapter.java

示例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();
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:7,代碼來源:SymbolVisitorAdapter.java

示例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");
}
 
開發者ID:rpau,項目名稱:javalang,代碼行數:77,代碼來源:ASTParser.java

示例12: visit

import org.walkmod.javalang.ast.stmt.TryStmt; //導入依賴的package包/類
public R visit(TryStmt n, A arg); 
開發者ID:rpau,項目名稱:javalang,代碼行數:2,代碼來源:GenericVisitor.java

示例13: visit

import org.walkmod.javalang.ast.stmt.TryStmt; //導入依賴的package包/類
public void visit(TryStmt n, A arg); 
開發者ID:rpau,項目名稱:javalang,代碼行數:2,代碼來源:VoidVisitor.java


注:本文中的org.walkmod.javalang.ast.stmt.TryStmt類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。