Search in sources :

Example 16 with Root

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

the class RegionAccessBuilderTest method testExpression2.

@Test
public void testExpression2() throws Exception {
    String model = "5 (a + b) + c\n".trim();
    String expectation = " 0 0 H\n" + "     B Add        Root\n" + " 0 1  S \"5\"        Root:'5'\n" + " 1 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "      B Add        Expression:{Add.left=} path:Add/left\n" + " 2 1   S \"(\"        Parenthesized:'('\n" + " 3 0   H\n" + "       B Named'a'   Expression:{Add.left=} path:Add/left=Add/left\n" + " 3 1    S \"a\"        Primary:name=ID\n" + "       E Named'a'   Expression:{Add.left=} path:Add/left=Add/left\n" + " 4 1   H \" \"        Whitespace:TerminalRule'WS'\n" + " 5 1   S \"+\"        Expression:'+'\n" + " 6 1   H \" \"        Whitespace:TerminalRule'WS'\n" + "       B Named'b'   Expression:right=Primary path:Add/right=Add/left\n" + " 7 1    S \"b\"        Primary:name=ID\n" + "       E Named'b'   Expression:right=Primary path:Add/right=Add/left\n" + " 8 0   H\n" + " 8 1   S \")\"        Parenthesized:')'\n" + "      E Add        Expression:{Add.left=} path:Add/left\n" + " 9 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "10 1  S \"+\"        Expression:'+'\n" + "11 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "      B Named'c'   Expression:right=Primary path:Add/right\n" + "12 1   S \"c\"        Primary:name=ID\n" + "      E Named'c'   Expression:right=Primary path:Add/right\n" + "     E Add        Root\n" + "13 0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 17 with Root

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

the class RegionAccessBuilderTest method testActionActionAction.

@Test
public void testActionActionAction() throws Exception {
    String model = "6 () action action\n".trim();
    String expectation = " 0 0 H\n" + "     B AssignedAction Root\n" + " 0 1  S \"6\"        Root:'6'\n" + " 1 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "      B AssignedAction Mixed:{AssignedAction.child=} path:AssignedAction/child\n" + "       B Action     Mixed:{AssignedAction.child=} path:AssignedAction/child=AssignedAction/child\n" + " 2 1    S \"(\"        Mixed:'('\n" + " 3 0    H\n" + " 3 1    S \")\"        Mixed:')'\n" + "       E Action     Mixed:{AssignedAction.child=} path:AssignedAction/child=AssignedAction/child\n" + " 4 1   H \" \"        Whitespace:TerminalRule'WS'\n" + " 5 6   S \"action\"   Mixed:'action'\n" + "      E AssignedAction Mixed:{AssignedAction.child=} path:AssignedAction/child\n" + "11 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "12 6  S \"action\"   Mixed:'action'\n" + "     E AssignedAction Root\n" + "18 0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 18 with Root

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

the class RegionAccessTestHelper method toTextRegionAccess.

public ITextRegionAccess toTextRegionAccess(CharSequence file) throws Exception {
    Root obj = parseHelper.parse(file.toString().replace("\r\n", "\n").trim());
    validationTestHelper.assertNoErrors(obj);
    return textRegionAccessBuilder.get().forNodeModel((XtextResource) obj.eResource()).create();
}
Also used : Root(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Root) XtextResource(org.eclipse.xtext.resource.XtextResource)

Example 19 with Root

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

the class RegionAccessBuilderTest method testAssignmentAction.

@Test
public void testAssignmentAction() throws Exception {
    String model = "6 (foo) action\n".trim();
    String expectation = " 0 0 H\n" + "     B AssignedAction Root\n" + " 0 1  S \"6\"        Root:'6'\n" + " 1 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "      B Mixed'foo' Mixed:{AssignedAction.child=} path:AssignedAction/child\n" + " 2 1   S \"(\"        Mixed:'('\n" + " 3 0   H\n" + " 3 3   S \"foo\"      Mixed:name=ID\n" + " 6 0   H\n" + " 6 1   S \")\"        Mixed:')'\n" + "      E Mixed'foo' Mixed:{AssignedAction.child=} path:AssignedAction/child\n" + " 7 1  H \" \"        Whitespace:TerminalRule'WS'\n" + " 8 6  S \"action\"   Mixed:'action'\n" + "     E AssignedAction Root\n" + "14 0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 20 with Root

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

the class RegionAccessBuilderTest method testAssignedDatatype2.

@Test
public void testAssignedDatatype2() throws Exception {
    String model = "6 (datatype datatype foo)\n".trim();
    String expectation = " 0  0 H\n" + "      B Mixed      Root\n" + " 0  1  S \"6\"        Root:'6'\n" + " 1  1  H \" \"        Whitespace:TerminalRule'WS'\n" + " 2  1  S \"(\"        Mixed:'('\n" + " 3  0  H\n" + " 3 21  S \"datat...\" Mixed:datatype=Datatype\n" + "24  0  H\n" + "24  1  S \")\"        Mixed:')'\n" + "      E Mixed      Root\n" + "25  0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)47 TextRegionAccessToString (org.eclipse.xtext.formatting2.debug.TextRegionAccessToString)32 ITextRegionAccess (org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess)21 ITextRegionDiffBuilder (org.eclipse.xtext.formatting2.regionaccess.ITextRegionDiffBuilder)16 ISemanticRegion (org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion)14 ITextRegionExtensions (org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions)6 Root (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Root)5 IEObjectRegion (org.eclipse.xtext.formatting2.regionaccess.IEObjectRegion)4 ValueList (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList)4 EObject (org.eclipse.emf.ecore.EObject)3 Delegate (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate)3 PrefixedUnassigned (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.PrefixedUnassigned)3 Delegation (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegation)2 EPackage (org.eclipse.emf.ecore.EPackage)1 EReference (org.eclipse.emf.ecore.EReference)1 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 IHiddenRegion (org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion)1