use of org.eclipse.n4js.flowgraphs.model.FlowGraph in project n4js by eclipse.
the class ControlFlowGraphFactory method build.
/**
* Builds and returns a control flow graph from a given {@link Script}.
*/
public static FlowGraph build(Script script) {
Set<ControlFlowElement> cfContainers = new LinkedHashSet<>();
Map<ControlFlowElement, ComplexNode> cnMap = new HashMap<>();
String uriString = script.eResource().getURI().toString();
ComplexNodeMapper cnMapper = null;
try (ClosableMeasurement m = dcCreateNodes.getClosableMeasurement("createNodes_" + uriString)) {
createComplexNodes(script, cfContainers, cnMap);
cnMapper = new ComplexNodeMapper(cnMap);
}
try (ClosableMeasurement m = dcConnectNodes.getClosableMeasurement("connectNodes_" + uriString)) {
connectComplexNodes(cnMapper);
}
try (ClosableMeasurement m = dcJumpEdges.getClosableMeasurement("jumpEdges_" + uriString)) {
createJumpEdges(cnMapper);
}
FlowGraph cfg = new FlowGraph(script, cfContainers, cnMap);
if (PRINT_EDGE_DETAILS)
printAllEdgeDetails(cnMapper);
return cfg;
}
Aggregations