use of org.eclipse.n4js.flowgraphs.ASTIterator in project n4js by eclipse.
the class FlowgraphsXpectMethod method astOrder.
/**
* This xpect method can evaluate the direct predecessors of a code element. The predecessors can be limited when
* specifying the edge type.
* <p>
* <b>Attention:</b> The type parameter <i>does not</i> work on self loops!
*/
@ParameterParser(syntax = "('of' arg2=OFFSET)?")
@Xpect
public void astOrder(@N4JSCommaSeparatedValuesExpectation IN4JSCommaSeparatedValuesExpectation expectation, IEObjectCoveringRegion offset) {
EObject context = offset.getEObject();
Iterator<ControlFlowElement> astIter = new ASTIterator(context);
int idx = 0;
List<String> astElements = new LinkedList<>();
while (astIter.hasNext()) {
ControlFlowElement cfe = astIter.next();
String elem = idx + ": " + FGUtils.getSourceText(cfe);
astElements.add(elem);
idx++;
}
expectation.assertEquals(astElements);
}
Aggregations