use of org.sonar.java.cfg.CFG in project sonar-java by SonarSource.
the class UCFGJavaVisitor method visitMethod.
@Override
public void visitMethod(MethodTree tree) {
super.visitMethod(tree);
if (tree.block() != null) {
CFG cfg = CFG.build(tree);
try {
UCFG uCFG = buildUCfg(tree, cfg);
UCFGtoProtobuf.toProtobufFile(uCFG, filePath());
} catch (Exception e) {
LOG.error("Cannot generate ucfg in file " + fileKey + " for method at line" + tree.firstToken().line(), e);
}
}
}
use of org.sonar.java.cfg.CFG in project sonar-java by SonarSource.
the class ProgramPointTest method test_to_string_method.
@Test
public void test_to_string_method() throws Exception {
// ToString method of program point is used by viewer.
CFG cfg = CFGTest.buildCFG("void foo() {foo();}");
ProgramPoint pp = new ProgramPoint(cfg.blocks().get(0));
assertThat(pp.toString()).isEqualTo("B1.0 IDENTIFIER1");
pp = pp.next().next();
assertThat(pp.toString()).isEqualTo("B1.2 ");
}
Aggregations