@Test public void test_cfg_failure_logs() { CompilationUnitTree tree = parse("<?php\n" + "function foo() {\n" + " break;\n" + "}\n", PHPLexicalGrammar.COMPILATION_UNIT); FunctionDeclarationTree func = (FunctionDeclarationTree) tree.script().statements().get(0); logTester.setLevel(LoggerLevel.DEBUG); ControlFlowGraph cfg = ControlFlowGraph.build(func, checkContext); assertThat(cfg).isNull(); assertThat(logTester.logs(LoggerLevel.WARN)).contains("Failed to build control flow graph for file [mock.php] at line 2 (activate debug logs for more details)"); assertThat(logTester.logs(LoggerLevel.DEBUG)).hasOnlyOneElementSatisfying(s -> assertThat(s).contains("com.sonar.sslr.api.RecognitionException: Failed to build CFG")); logTester.clear(); logTester.setLevel(LoggerLevel.INFO); cfg = ControlFlowGraph.build(func, checkContext); assertThat(cfg).isNull(); assertThat(logTester.logs()).isEmpty(); }
@VisibleForTesting public static ControlFlowGraph build(BlockTree body) { return new ControlFlowGraphBuilder(body.statements()).getGraph(); }
ControlFlowGraph { @VisibleForTesting public static ControlFlowGraph build(BlockTree body) { return new ControlFlowGraphBuilder(body.statements()).getGraph(); } }
ControlFlowGraph { @VisibleForTesting public static ControlFlowGraph build(BlockTree body) { return new ControlFlowGraphBuilder(body.statements()).getGraph(); } ControlFlowGraph(ImmutableSet<CfgBlock> blocks, CfgBlock start, PhpCfgEndBlock end); }
ControlFlowGraph { @VisibleForTesting public static ControlFlowGraph build(BlockTree body) { return new ControlFlowGraphBuilder(body.statements()).getGraph(); } ControlFlowGraph(ImmutableSet<CfgBlock> blocks, CfgBlock start, PhpCfgEndBlock end); @VisibleForTesting static ControlFlowGraph build(BlockTree body); @CheckForNull static ControlFlowGraph build(Tree tree, CheckContext context); CfgBlock start(); CfgBlock end(); Set<CfgBlock> blocks(); }
ControlFlowGraph { @VisibleForTesting public static ControlFlowGraph build(BlockTree body) { return new ControlFlowGraphBuilder(body.statements()).getGraph(); } ControlFlowGraph(ImmutableSet<CfgBlock> blocks, CfgBlock start, PhpCfgEndBlock end); @VisibleForTesting static ControlFlowGraph build(BlockTree body); @CheckForNull static ControlFlowGraph build(Tree tree, CheckContext context); CfgBlock start(); CfgBlock end(); Set<CfgBlock> blocks(); static final Set<Tree.Kind> KINDS_WITH_CONTROL_FLOW; }