Search in sources :

Example 1 with AllBranchPrintVisitor

use of org.eclipse.n4js.flowgraphs.analysers.AllBranchPrintVisitor in project n4js by eclipse.

the class FlowgraphsXpectMethod method performBranchAnalysis.

private AllBranchPrintVisitor performBranchAnalysis(IEObjectCoveringRegion offset, String directionName, IEObjectCoveringRegion referenceOffset) {
    EObjectCoveringRegion offsetImpl = (EObjectCoveringRegion) offset;
    EObjectCoveringRegion referenceOffsetImpl = (EObjectCoveringRegion) referenceOffset;
    ControlFlowElement startCFE = getCFEWithReference(offsetImpl, referenceOffsetImpl);
    ControlFlowElement referenceCFE = getCFE(referenceOffset);
    TraverseDirection direction = getDirection(directionName);
    ControlFlowElement container = FGUtils.getCFContainer(referenceCFE);
    AllBranchPrintVisitor appw = new AllBranchPrintVisitor(container, startCFE, direction);
    getFlowAnalyzer(referenceCFE).accept(appw);
    return appw;
}
Also used : AllBranchPrintVisitor(org.eclipse.n4js.flowgraphs.analysers.AllBranchPrintVisitor) IEObjectCoveringRegion(org.eclipse.n4js.xpect.common.N4JSOffsetAdapter.IEObjectCoveringRegion) EObjectCoveringRegion(org.eclipse.n4js.xpect.common.N4JSOffsetAdapter.EObjectCoveringRegion) TraverseDirection(org.eclipse.n4js.flowgraphs.analysis.TraverseDirection) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement)

Example 2 with AllBranchPrintVisitor

use of org.eclipse.n4js.flowgraphs.analysers.AllBranchPrintVisitor in project n4js by eclipse.

the class FlowgraphsXpectMethod method allPaths.

/**
 * This xpect method can evaluate all paths from a given start code element. If no start code element is specified,
 * the first code element of the containing function.
 */
@ParameterParser(syntax = "('from' arg1=OFFSET)? ('direction' arg2=STRING)? ('pleaseNeverUseThisParameterSinceItExistsOnlyToGetAReferenceOffset' arg3=OFFSET)?")
@Xpect
public void allPaths(@N4JSCommaSeparatedValuesExpectation IN4JSCommaSeparatedValuesExpectation expectation, IEObjectCoveringRegion offset, String directionName, IEObjectCoveringRegion referenceOffset) {
    AllBranchPrintVisitor appw = performBranchAnalysis(offset, directionName, referenceOffset);
    List<String> pathStrings = appw.getPathStrings();
    expectation.assertEquals(pathStrings);
}
Also used : AllBranchPrintVisitor(org.eclipse.n4js.flowgraphs.analysers.AllBranchPrintVisitor) Xpect(org.eclipse.xpect.runner.Xpect) ParameterParser(org.eclipse.xpect.parameter.ParameterParser)

Example 3 with AllBranchPrintVisitor

use of org.eclipse.n4js.flowgraphs.analysers.AllBranchPrintVisitor in project n4js by eclipse.

the class FlowgraphsXpectMethod method allBranches.

/**
 * This xpect method can evaluate all branches from a given start code element. If no start code element is
 * specified, the first code element of the containing function.
 */
@ParameterParser(syntax = "('from' arg1=OFFSET)? ('direction' arg2=STRING)? ('pleaseNeverUseThisParameterSinceItExistsOnlyToGetAReferenceOffset' arg3=OFFSET)?")
@Xpect
public void allBranches(@N4JSCommaSeparatedValuesExpectation IN4JSCommaSeparatedValuesExpectation expectation, IEObjectCoveringRegion offset, String directionName, IEObjectCoveringRegion referenceOffset) {
    AllBranchPrintVisitor appw = performBranchAnalysis(offset, directionName, referenceOffset);
    List<String> branchStrings = appw.getBranchStrings();
    expectation.assertEquals(branchStrings);
}
Also used : AllBranchPrintVisitor(org.eclipse.n4js.flowgraphs.analysers.AllBranchPrintVisitor) Xpect(org.eclipse.xpect.runner.Xpect) ParameterParser(org.eclipse.xpect.parameter.ParameterParser)

Aggregations

AllBranchPrintVisitor (org.eclipse.n4js.flowgraphs.analysers.AllBranchPrintVisitor)3 ParameterParser (org.eclipse.xpect.parameter.ParameterParser)2 Xpect (org.eclipse.xpect.runner.Xpect)2 TraverseDirection (org.eclipse.n4js.flowgraphs.analysis.TraverseDirection)1 ControlFlowElement (org.eclipse.n4js.n4JS.ControlFlowElement)1 EObjectCoveringRegion (org.eclipse.n4js.xpect.common.N4JSOffsetAdapter.EObjectCoveringRegion)1 IEObjectCoveringRegion (org.eclipse.n4js.xpect.common.N4JSOffsetAdapter.IEObjectCoveringRegion)1