Search in sources :

Example 1 with Match

use of org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match in project n4js by eclipse.

the class XtIdeTest method succs.

/**
 * This xpect method can evaluate the direct successors of a code element. The successors can be limited when
 * specifying the edge type.
 *
 * <pre>
 * // Xpect succs type '{@link ControlFlowType#values()}' at '&ltLOCATION&gt' --&gt; &ltSUCCESSORS&gt
 * </pre>
 *
 * The type is optional. If given, the result is filtered accordingly. The type parameter does not work on self
 * loops.
 *
 * SUCCESSORS is a comma separated list.
 */
// NOTE: This annotation is used only to enable validation and navigation of .xt files.
@Xpect
public void succs(XtMethodData data) {
    Match match = PATTERN_SUCCS.match(data, eobjProvider);
    String type = match.getText("type");
    IEObjectCoveringRegion ocrAt = match.getEObjectWithOffset("at");
    List<String> succTexts = xtFlowgraphs.getSuccs(type, ocrAt);
    assertEqualIterables(data.expectation, succTexts);
}
Also used : Match(org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match) Xpect(org.eclipse.xpect.runner.Xpect)

Example 2 with Match

use of org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match in project n4js by eclipse.

the class XtIdeTest method preds.

/**
 * This xpect method can evaluate the direct predecessors of a code element. The predecessors can be limited when
 * specifying the edge type.
 *
 * <pre>
 * // Xpect preds type '{@link ControlFlowType#values()}' at '&ltLOCATION&gt' --&gt; &ltPREDECESSORS&gt
 * </pre>
 *
 * The type is optional. If given, the result is filtered accordingly. The type parameter does not work on self
 * loops.
 *
 * PREDECESSORS is a comma separated list.
 */
// NOTE: This annotation is used only to enable validation and navigation of .xt files.
@Xpect
public void preds(XtMethodData data) {
    Match match = PATTERN_PREDS.match(data, eobjProvider);
    String type = match.getText("type");
    IEObjectCoveringRegion ocrAt = match.getEObjectWithOffset("at");
    List<String> predTexts = xtFlowgraphs.getPreds(type, ocrAt);
    assertEqualIterables(data.expectation, predTexts);
}
Also used : Match(org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match) Xpect(org.eclipse.xpect.runner.Xpect)

Example 3 with Match

use of org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match in project n4js by eclipse.

the class XtIdeTest 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.
 *
 * <pre>
 * // Xpect allBranches from '&ltLOCATION&gt' direction '&lt{@link TraverseDirection#values()}&gt' --&gt;
 * // &ltBRANCHES&gt
 * </pre>
 *
 * The direction is optional.
 *
 * BRANCHES is a comma separated list.
 */
// NOTE: This annotation is used only to enable validation and navigation of .xt files.
@Xpect
public void allBranches(XtMethodData data) {
    Match match = PATTERN_ALLBRANCHES.match(data, eobjProvider);
    String direction = match.getText("direction");
    IEObjectCoveringRegion ocrReference = match.ocrReference;
    IEObjectCoveringRegion ocrFrom = match.getEObjectWithOffset("from");
    List<String> branchStrings = xtFlowgraphs.getAllBranches(ocrFrom, direction, ocrReference);
    assertEqualIterables(data.expectation, branchStrings);
}
Also used : Match(org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match) Xpect(org.eclipse.xpect.runner.Xpect)

Example 4 with Match

use of org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match in project n4js by eclipse.

the class XtIdeTest 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.
 *
 * <pre>
 * // Xpect allPaths from '&ltLOCATION&gt' direction '&lt{@link TraverseDirection#values()}&gt' --&gt; &ltPATHS&gt
 * </pre>
 *
 * The direction is optional.
 *
 * PATHS is a comma separated list.
 */
// NOTE: This annotation is used only to enable validation and navigation of .xt files.
@Xpect
public void allPaths(XtMethodData data) {
    Match match = PATTERN_ALLPATHS.match(data, eobjProvider);
    String direction = match.getText("direction");
    IEObjectCoveringRegion ocrReference = match.ocrReference;
    IEObjectCoveringRegion ocrFrom = match.getEObjectWithOffset("from");
    List<String> pathStrings = xtFlowgraphs.getAllPaths(ocrFrom, direction, ocrReference);
    assertEqualIterables(data.expectation, pathStrings);
}
Also used : Match(org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match) Xpect(org.eclipse.xpect.runner.Xpect)

Example 5 with Match

use of org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match in project n4js by eclipse.

the class XtIdeTest method commonPreds.

/**
 * This xpect method can evaluate all common predecessors of two {@link ControlFlowElement}s.
 *
 * <pre>
 * // Xpect cfContainer of '&ltLOCATION A&gt' and '&ltLOCATION B&gt' --&gt; &ltCOMMON PREDECESSORS&gt
 * </pre>
 *
 * COMMON PREDECESSORS is a comma separated list.
 */
// NOTE: This annotation is used only to enable validation and navigation of .xt files.
@Xpect
public void commonPreds(XtMethodData data) {
    Match match = PATTERN_COMMONPREDS.match(data, eobjProvider);
    IEObjectCoveringRegion ocrA = match.getEObjectWithOffset("of");
    IEObjectCoveringRegion ocrB = match.getEObjectWithOffset("and");
    List<String> commonPredStrs = xtFlowgraphs.getCommonPreds(ocrA, ocrB);
    assertEqualIterables(data.expectation, commonPredStrs);
}
Also used : Match(org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match) Xpect(org.eclipse.xpect.runner.Xpect)

Aggregations

Match (org.eclipse.n4js.ide.tests.helper.server.xt.XtMethodPattern.Match)6 Xpect (org.eclipse.xpect.runner.Xpect)6