use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.
the class FlowgraphsXpectMethod method cfContainer.
/**
* This xpect method can evaluate the control flow container of a given {@link ControlFlowElement}.
*/
@ParameterParser(syntax = "('of' arg1=OFFSET)?")
@Xpect
public void cfContainer(@StringExpectation IStringExpectation expectation, IEObjectCoveringRegion offset) {
ControlFlowElement cfe = getCFE(offset);
ControlFlowElement container = getFlowAnalyzer(cfe).getContainer(cfe);
EObject containerContainer = container.eContainer();
String ccString = (containerContainer != null) ? FGUtils.getClassName(containerContainer) + "::" : "";
String containerStr = ccString + FGUtils.getClassName(container);
expectation.assertEquals(containerStr);
}
use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.
the class SuccessorPredecessorAnalysis method getSuccessorsSkipInternal.
/**
* see {@link N4JSFlowAnalyser#getSuccessorsSkipInternal(ControlFlowElement)}
*/
public Set<ControlFlowElement> getSuccessorsSkipInternal(ControlFlowElement cfe) {
NextEdgesProvider nextEdgesProvider = new NextEdgesProvider.Forward();
Node nextNode = getNextNode(cfe, true, nextEdgesProvider);
Set<ControlFlowElement> successors = getNextCFEs(nextEdgesProvider, cfe, nextNode);
return successors;
}
use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.
the class SuccessorPredecessorAnalysis method getSuccessors.
/**
* see {@link N4JSFlowAnalyser#getSuccessors(ControlFlowElement)}
*/
public Set<ControlFlowElement> getSuccessors(ControlFlowElement cfe) {
NextEdgesProvider nextEdgesProvider = new NextEdgesProvider.Forward();
Node nextNode = getNextNode(cfe, false, nextEdgesProvider);
Set<ControlFlowElement> successors = getNextCFEs(nextEdgesProvider, cfe, nextNode);
return successors;
}
use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.
the class SuccessorPredecessorAnalysis method getNextCFEs.
/**
* @return the set of all next {@link ControlFlowElement}
*/
private Set<ControlFlowElement> getNextCFEs(NextEdgesProvider nextEdgesProvider, ControlFlowElement cfe, Node nextNode) {
Objects.requireNonNull(cfe);
Set<ControlFlowElement> nexts = new HashSet<>();
LinkedList<ControlFlowEdge> allEdges = new LinkedList<>();
List<ControlFlowEdge> nextEdges = nextEdgesProvider.getNextEdges(nextNode, ControlFlowType.NonDeadTypes);
allEdges.addAll(nextEdges);
while (!allEdges.isEmpty()) {
ControlFlowEdge nextEdge = allEdges.removeFirst();
nextNode = nextEdgesProvider.getNextNode(nextEdge);
if (nextNode instanceof RepresentingNode) {
ControlFlowElement succ = nextNode.getRepresentedControlFlowElement();
nexts.add(succ);
} else {
nextEdges = nextEdgesProvider.getNextEdges(nextNode, ControlFlowType.NonDeadTypes);
allEdges.addAll(nextEdges);
}
}
return nexts;
}
use of org.eclipse.n4js.n4JS.ControlFlowElement in project n4js by eclipse.
the class SuccessorPredecessorAnalysis method getPredecessorsSkipInternal.
/**
* see {@link N4JSFlowAnalyser#getPredecessorsSkipInternal(ControlFlowElement)}
*/
public Set<ControlFlowElement> getPredecessorsSkipInternal(ControlFlowElement cfe) {
NextEdgesProvider nextEdgesProvider = new NextEdgesProvider.Backward();
Node nextNode = getNextNode(cfe, true, nextEdgesProvider);
Set<ControlFlowElement> predecessors = getNextCFEs(nextEdgesProvider, cfe, nextNode);
return predecessors;
}
Aggregations