Newer
Older
import com.github.javaparser.ast.stmt.EmptyStmt;
import com.github.javaparser.ast.stmt.Statement;
import java.util.Comparator;
import java.util.stream.Collectors;
setRootVertex(new CFGNode<>(getNextVertexId(), getRootNodeData(), new EmptyStmt()));
public <ASTNode extends Node> CFGNode<ASTNode> addNode(String instruction, ASTNode node) {
CFGNode<ASTNode> vertex = new CFGNode<>(getNextVertexId(), instruction, node);
protected String getRootNodeData() {
return "Start";
}
public void addControlFlowEdge(CFGNode from, CFGNode to) {
@Override
public String toGraphvizRepresentation() {
String lineSep = System.lineSeparator();
.map(node -> String.format("%s [label=\"%s: %s\"]", node.getId(), node.getId(), node.getData()))
.collect(Collectors.joining(lineSep));
.sorted(Comparator.comparingInt(arrow -> ((GraphNode) arrow.getFrom()).getId()))
.map(arrow -> ((Arc) arrow).toGraphvizRepresentation())
.collect(Collectors.joining(lineSep));
return "digraph g{" + lineSep +
public Graph<CFGNode<?>> slice(SlicingCriterion slicingCriterion) {