use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegionsFinder in project xtext-core by eclipse.
the class SemanticRegionFinderTest method regionForCrossReference.
@Test
public void regionForCrossReference() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("6 (ref foo) action (foo) end");
final AssignedAction mixed = this.<AssignedAction>parseAs(_builder, AssignedAction.class);
final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed.getChild()).getRegionFor();
final ISemanticRegion actual = finder.crossRef(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getRefMixedCrossReference_2_2_3_1_0());
final List<ISemanticRegion> actuals = finder.crossRefs(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getRefMixedCrossReference_2_2_3_1_0());
this.assertEquals("foo", actual, actuals);
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegionsFinder in project xtext-core by eclipse.
the class SemanticRegionFinderTest method regionForKeywordPairs2.
@Test
public void regionForKeywordPairs2() {
@Extension final RegionAccessTestLanguageGrammarAccess.ParenthesizedElements rule = this._regionAccessTestLanguageGrammarAccess.getParenthesizedAccess();
StringConcatenation _builder = new StringConcatenation();
_builder.append("5 (a + ((b) + c) + d)");
final Expression expr = this.<Expression>parseAs(_builder, Expression.class);
final ISemanticRegionsFinder finder = this.toAccess(expr).regionForRootEObject().getAllRegionsFor();
final String actual1 = this.pairsToString(finder.keywordPairs("(", ")"));
final String actual2 = this.pairsToString(finder.keywordPairs(rule.getLeftParenthesisKeyword_0(), rule.getRightParenthesisKeyword_2()));
final String expected = "(b); ((b) + c); (a + ((b) + c) + d)";
Assert.assertEquals(expected, actual1);
Assert.assertEquals(expected, actual2);
}
Aggregations