@Test void try_statement_with_CFG_blocks() { CFG cfg = buildCFG( " private void f(boolean action) {\n" + " try {\n" + " if (action) {" + " performAction();" + " }" + " doSomething();" + "} catch(Exception e) { foo();} bar(); }"); CFGChecker cfgChecker = checker( block( element(Tree.Kind.TRY_STATEMENT)).successors(5), block( element(Tree.Kind.IDENTIFIER, "action")).terminator(Kind.IF_STATEMENT).successors(3, 4), block( element(Tree.Kind.IDENTIFIER, "performAction"), element(Kind.METHOD_INVOCATION)).successors(3).exceptions(0, 2).exit(0), block( element(Tree.Kind.IDENTIFIER, "doSomething"), element(Kind.METHOD_INVOCATION)).successors(1).exceptions(0, 2).exit(0), block( element(Kind.VARIABLE, "e"), element(Tree.Kind.IDENTIFIER, "foo"), element(Kind.METHOD_INVOCATION)).successors(1).exceptions(0).exit(0), block( element(Tree.Kind.IDENTIFIER, "bar"), element(Kind.METHOD_INVOCATION)).successors(0)); cfgChecker.check(cfg); cfg = buildCFG( " private void f(boolean action) {\n" + " try {\n" + " doSomething();" + " if (action) {" + " performAction();" + " }" + "} catch(Exception e) { foo();} bar(); }"); cfgChecker = checker( block( element(Tree.Kind.TRY_STATEMENT)).successors(5), block( element(Tree.Kind.IDENTIFIER, "doSomething"), element(Kind.METHOD_INVOCATION)).successors(4).exceptions(0, 2).exit(0), block( element(Tree.Kind.IDENTIFIER, "action")).terminator(Kind.IF_STATEMENT).successors(1, 3), block( element(Tree.Kind.IDENTIFIER, "performAction"), element(Kind.METHOD_INVOCATION)).successors(1).exceptions(0, 2), block( element(Kind.VARIABLE, "e"), element(Tree.Kind.IDENTIFIER, "foo"), element(Kind.METHOD_INVOCATION)).successors(1).exceptions(0), block( element(Tree.Kind.IDENTIFIER, "bar"), element(Kind.METHOD_INVOCATION)).successors(0)); cfgChecker.check(cfg); cfg = buildCFG( " private void f(boolean action) {\n" + " try {\n" + " if (action) {" + " performAction();" + " }" + " doSomething();" + "} finally { foo();} bar(); }"); cfgChecker = checker( block( element(Tree.Kind.TRY_STATEMENT)).successors(5), block( element(Tree.Kind.IDENTIFIER, "action")).terminator(Kind.IF_STATEMENT).successors(3, 4), block( element(Tree.Kind.IDENTIFIER, "performAction"), element(Kind.METHOD_INVOCATION)).successors(3).exceptions(2), block( element(Tree.Kind.IDENTIFIER, "doSomething"), element(Kind.METHOD_INVOCATION)).successors(2).exceptions(2), block( element(Tree.Kind.IDENTIFIER, "foo"), element(Kind.METHOD_INVOCATION)).successors(0, 1), block( element(Tree.Kind.IDENTIFIER, "bar"), element(Kind.METHOD_INVOCATION)).successors(0)); cfgChecker.check(cfg); }
public static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak) { return new CFG(trees, null, ignoreBreak); }
CFG implements ControlFlowGraph { public static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak) { return new CFG(trees, null, ignoreBreak); } }
CFG implements ControlFlowGraph { public static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak) { return new CFG(trees, null, ignoreBreak); } private  CFG(List<? extends Tree> trees, @Nullable Symbol.MethodSymbol symbol, boolean ignoreBreakAndContinue); }
CFG implements ControlFlowGraph { public static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak) { return new CFG(trees, null, ignoreBreak); } private  CFG(List<? extends Tree> trees, @Nullable Symbol.MethodSymbol symbol, boolean ignoreBreakAndContinue); @Override Block exitBlock(); @Nullable Symbol.MethodSymbol methodSymbol(); @Override Block entryBlock(); @Override List<Block> blocks(); List<Block> reversedBlocks(); static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak); static CFG buildCFG(List<? extends Tree> trees); static CFG build(MethodTree tree); void setMethodSymbol(Symbol.MethodSymbol methodSymbol); }
CFG implements ControlFlowGraph { public static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak) { return new CFG(trees, null, ignoreBreak); } private  CFG(List<? extends Tree> trees, @Nullable Symbol.MethodSymbol symbol, boolean ignoreBreakAndContinue); @Override Block exitBlock(); @Nullable Symbol.MethodSymbol methodSymbol(); @Override Block entryBlock(); @Override List<Block> blocks(); List<Block> reversedBlocks(); static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak); static CFG buildCFG(List<? extends Tree> trees); static CFG build(MethodTree tree); void setMethodSymbol(Symbol.MethodSymbol methodSymbol);  }