use of org.eclipse.n4js.flowgraphs.model.Node 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);
}
use of org.eclipse.n4js.flowgraphs.model.Node in project n4js by eclipse.
the class SuccessorPredecessorAnalysis method getPredecessors.
/**
* see {@link N4JSFlowAnalyser#getPredecessors(ControlFlowElement)}
*/
public Set<ControlFlowElement> getPredecessors(ControlFlowElement cfe) {
NextEdgesProvider nextEdgesProvider = new NextEdgesProvider.Backward();
Node nextNode = getNextNode(cfe, false, nextEdgesProvider);
Set<ControlFlowElement> predecessors = getNextCFEs(nextEdgesProvider, cfe, nextNode);
return predecessors;
}
use of org.eclipse.n4js.flowgraphs.model.Node in project n4js by eclipse.
the class GraphVisitorGuideInternal method mergeEdgeGuides.
private void mergeEdgeGuides() {
List<EdgeGuide> joinGuideGroup = guideWorklist.getJoinGroups();
if (!joinGuideGroup.isEmpty()) {
EdgeGuide firstEG = joinGuideGroup.get(0);
// end node is the same of all EGs in the list
Node endNode = firstEG.getNextNode();
for (EdgeGuide eg : joinGuideGroup) {
Node startNode = eg.getPrevNode();
// Before merging the join group, the edges are visited.
callVisitOnEdge(startNode, eg, endNode);
}
EdgeGuide mergedEG = guideWorklist.mergeJoinGroup(joinGuideGroup);
callVisitOnNode(mergedEG, endNode);
}
}
use of org.eclipse.n4js.flowgraphs.model.Node in project n4js by eclipse.
the class Path method walkMe.
private void walkMe(IPathWalkerInternal walker) {
walker.visitNode(start);
for (ControlFlowEdge edge : edges) {
Node bNode = nextEdgesProvider.getPrevNode(edge);
Node fNode = nextEdgesProvider.getNextNode(edge);
walker.visitEdge(bNode, fNode, edge);
walker.visitNode(fNode);
}
}
use of org.eclipse.n4js.flowgraphs.model.Node in project n4js by eclipse.
the class N4JSFlowAnalyserDataRecorder method compareNodes.
static int compareNodes(Pair<Node, List<ControlFlowEdge>> p1, Pair<Node, List<ControlFlowEdge>> p2) {
Node n1 = p1.getKey();
Node n2 = p2.getKey();
return n1.getExtendedString().compareTo(n2.getExtendedString());
}
Aggregations