Search in sources :

Example 1 with Expression

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Expression in project xtext-core by eclipse.

the class RegionAccessBuilderTest method testExpression1.

@Test
public void testExpression1() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("5 a + b");
    _builder.newLine();
    String _trim = _builder.toString().trim();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("0 0 H");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("B Add        Root");
    _builder_1.newLine();
    _builder_1.append("0 1  S \"5\"        Root:\'5\'");
    _builder_1.newLine();
    _builder_1.append("1 1  H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("     ");
    _builder_1.append("B Named\'a\'   Expression:{Add.left=} path:Add/left");
    _builder_1.newLine();
    _builder_1.append("2 1   S \"a\"        Primary:name=ID");
    _builder_1.newLine();
    _builder_1.append("     ");
    _builder_1.append("E Named\'a\'   Expression:{Add.left=} path:Add/left");
    _builder_1.newLine();
    _builder_1.append("3 1  H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("4 1  S \"+\"        Expression:\'+\'");
    _builder_1.newLine();
    _builder_1.append("5 1  H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("     ");
    _builder_1.append("B Named\'b\'   Expression:right=Primary path:Add/right");
    _builder_1.newLine();
    _builder_1.append("6 1   S \"b\"        Primary:name=ID");
    _builder_1.newLine();
    _builder_1.append("     ");
    _builder_1.append("E Named\'b\'   Expression:right=Primary path:Add/right");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("E Add        Root");
    _builder_1.newLine();
    _builder_1.append("7 0 H");
    _builder_1.newLine();
    this.operator_tripleEquals(_trim, _builder_1);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 2 with Expression

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Expression in project xtext-core by eclipse.

the class RegionAccessBuilderTest method testExpression2.

@Test
public void testExpression2() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("5 (a + b) + c");
    _builder.newLine();
    String _trim = _builder.toString().trim();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append(" ");
    _builder_1.append("0 0 H");
    _builder_1.newLine();
    _builder_1.append("     ");
    _builder_1.append("B Add        Root");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("0 1  S \"5\"        Root:\'5\'");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("1 1  H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("B Add        Expression:{Add.left=} path:Add/left");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("2 1   S \"(\"        Parenthesized:\'(\'");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("3 0   H");
    _builder_1.newLine();
    _builder_1.append("       ");
    _builder_1.append("B Named\'a\'   Expression:{Add.left=} path:Add/left=Add/left");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("3 1    S \"a\"        Primary:name=ID");
    _builder_1.newLine();
    _builder_1.append("       ");
    _builder_1.append("E Named\'a\'   Expression:{Add.left=} path:Add/left=Add/left");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("4 1   H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("5 1   S \"+\"        Expression:\'+\'");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("6 1   H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("       ");
    _builder_1.append("B Named\'b\'   Expression:right=Primary path:Add/right=Add/left");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("7 1    S \"b\"        Primary:name=ID");
    _builder_1.newLine();
    _builder_1.append("       ");
    _builder_1.append("E Named\'b\'   Expression:right=Primary path:Add/right=Add/left");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("8 0   H");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("8 1   S \")\"        Parenthesized:\')\'");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("E Add        Expression:{Add.left=} path:Add/left");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("9 1  H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("10 1  S \"+\"        Expression:\'+\'");
    _builder_1.newLine();
    _builder_1.append("11 1  H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("B Named\'c\'   Expression:right=Primary path:Add/right");
    _builder_1.newLine();
    _builder_1.append("12 1   S \"c\"        Primary:name=ID");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("E Named\'c\'   Expression:right=Primary path:Add/right");
    _builder_1.newLine();
    _builder_1.append("     ");
    _builder_1.append("E Add        Root");
    _builder_1.newLine();
    _builder_1.append("13 0 H");
    _builder_1.newLine();
    this.operator_tripleEquals(_trim, _builder_1);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 3 with Expression

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Expression in project xtext-core by eclipse.

the class AddImpl method basicSetLeft.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetLeft(Expression newLeft, NotificationChain msgs) {
    Expression oldLeft = left;
    left = newLeft;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RegionaccesstestlanguagePackage.ADD__LEFT, oldLeft, newLeft);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 4 with Expression

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Expression in project xtext-core by eclipse.

the class AddImpl method basicSetRight.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetRight(Expression newRight, NotificationChain msgs) {
    Expression oldRight = right;
    right = newRight;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RegionaccesstestlanguagePackage.ADD__RIGHT, oldRight, newRight);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 5 with Expression

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Expression in project xtext-core by eclipse.

the class SemanticRegionFinderTest method regionForKeywordPairs.

@Test
public void regionForKeywordPairs() {
    @Extension final RegionAccessTestLanguageGrammarAccess.ParenthesizedElements rule = this._regionAccessTestLanguageGrammarAccess.getParenthesizedAccess();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("5 (foo)");
    final Expression expr = this.<Expression>parseAs(_builder, Expression.class);
    final ISemanticRegionsFinder finder = this.toAccess(expr).regionForEObject(expr).getRegionFor();
    final String actual1 = this.pairsToString(finder.keywordPairs("(", ")"));
    final String actual2 = this.pairsToString(finder.keywordPairs(rule.getLeftParenthesisKeyword_0(), rule.getRightParenthesisKeyword_2()));
    final String expected = "(foo)";
    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