use of org.eclipse.n4js.flowgraphs.analysis.GraphVisitor in project n4js by eclipse.
the class FlowgraphsXpectMethod method allMergeBranches.
/**
* This xpect method can evaluate all branches that are merged at the given node name.
*/
@ParameterParser(syntax = "('pleaseNeverUseThisParameterSinceItExistsOnlyToGetAReferenceOffset' arg1=OFFSET)?")
@Xpect
public void allMergeBranches(@N4JSCommaSeparatedValuesExpectation IN4JSCommaSeparatedValuesExpectation expectation, IEObjectCoveringRegion referenceOffset) {
N4JSFlowAnalyserDataRecorder.setEnabled(true);
GraphVisitor dfv = new DummyForwardVisitor();
GraphVisitor dbv = new DummyBackwardVisitor();
ControlFlowElement referenceCFE = getCFE(referenceOffset);
getFlowAnalyzer(referenceCFE).accept(dfv, dbv);
N4JSFlowAnalyserDataRecorder.setEnabled(false);
performBranchAnalysis(referenceOffset, null, referenceOffset);
List<String> edgeStrings = new LinkedList<>();
int groupIdx = 0;
List<Pair<Node, List<ControlFlowEdge>>> mergedEdges = N4JSFlowAnalyserDataRecorder.getMergedEdges();
for (Pair<Node, List<ControlFlowEdge>> pair : mergedEdges) {
Node startNode = pair.getKey();
List<ControlFlowEdge> edges = pair.getValue();
for (ControlFlowEdge edge : edges) {
String c = edge.start == startNode ? "B" : "F";
edgeStrings.add(c + groupIdx + ": " + edge.toString());
}
groupIdx++;
}
Collections.sort(edgeStrings);
expectation.assertEquals(edgeStrings);
}
Aggregations