Search in sources :

Example 6 with Expression

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Expression 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);
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) Expression(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Expression) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) RegionAccessTestLanguageGrammarAccess(org.eclipse.xtext.formatting2.regionaccess.internal.services.RegionAccessTestLanguageGrammarAccess) ISemanticRegionsFinder(org.eclipse.xtext.formatting2.regionaccess.ISemanticRegionsFinder) Test(org.junit.Test)

Aggregations

StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)4 Expression (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Expression)4 Test (org.junit.Test)4 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 TextRegionAccessToString (org.eclipse.xtext.formatting2.debug.TextRegionAccessToString)2 ISemanticRegionsFinder (org.eclipse.xtext.formatting2.regionaccess.ISemanticRegionsFinder)2 RegionAccessTestLanguageGrammarAccess (org.eclipse.xtext.formatting2.regionaccess.internal.services.RegionAccessTestLanguageGrammarAccess)2 Extension (org.eclipse.xtext.xbase.lib.Extension)2