Search in sources :

Example 6 with Root

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

the class RegionAccessCommentsTest method testDeleteFirstRegion3.

@Test
public void testDeleteFirstRegion3() throws Exception {
    String model = "/*h*/\n" + "/*81*/\n" + "\n" + "/*82*/\n" + "8 //8\n" + "/*a*/\n" + "a\n";
    ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
    ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
        ISemanticRegion foo = access.regionForRootEObject().getAllRegionsFor().keyword("8");
        it.remove(foo);
    });
    String expectation = " 0    1 H \"/*h*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "        \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + "        \"/*81*/\"   Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "        \"\\n" + "\\n" + "\"     Whitespace:TerminalRule'WS'\n" + "        \"/*a*/\"    Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + "   20   \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + "        B ValueList'[a]' Root\n" + "20  1    S \"a\"        ValueList:name+=ID\n" + "        E ValueList'[a]' Root\n" + "21  0   H\n" + "------------ diff 1 ------------\n" + " 0    H \"/*h*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "        \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + "        \"/*81*/\"   Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "        \"\\n" + "\\n" + "\"     Whitespace:TerminalRule'WS'\n" + "        \"/*82*/\"   Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + "   21   \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + "21  1 S \"8\"        Root:'8'\n" + "22    H \" \"        Whitespace:TerminalRule'WS'\n" + "        \"//8\\n" + "\"    Comment:TerminalRule'SL_COMMENT' Association:PREVIOUS\n" + "        \"/*a*/\"    Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + "   11   \"\\n" + "\"       Whitespace:TerminalRule'WS'\n";
    regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) ITextRegionDiffBuilder(org.eclipse.xtext.formatting2.regionaccess.ITextRegionDiffBuilder) ISemanticRegion(org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion) Test(org.junit.Test)

Example 7 with Root

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

the class RegionAccessBuilderTest method testFragmentRecursionChild.

@Test
public void testFragmentRecursionChild() throws Exception {
    String model = "6 (fragment recursion child ())\n".trim();
    String expectation = " 0 0 H\n" + "     B Action     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 8  S \"fragment\" Mixed:'fragment'\n" + "11 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "12 9  S \"recur...\" Fragment:'recursion'\n" + "21 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "22 5  S \"child\"    Fragment:'child'\n" + "27 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "      B Action     Fragment:mixed=Mixed path:Action/mixed\n" + "28 1   S \"(\"        Mixed:'('\n" + "29 0   H\n" + "29 1   S \")\"        Mixed:')'\n" + "      E Action     Fragment:mixed=Mixed path:Action/mixed\n" + "30 0  H\n" + "30 1  S \")\"        Mixed:')'\n" + "     E Action     Root\n" + "31 0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 8 with Root

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

the class RegionAccessBuilderTest method testMixedRootAction.

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

Example 9 with Root

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

the class RegionAccessBuilderTest method testUnassignedDelegate.

@Test
public void testUnassignedDelegate() throws Exception {
    String model = "3 foo\n".trim();
    String expectation = "0 0 H\n" + "    B Delegate'foo' Root\n" + "0 1  S \"3\"        Unassigned:'3'\n" + "1 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "2 3  S \"foo\"      Delegate:name=ID\n" + "    E Delegate'foo' Root\n" + "5 0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 10 with Root

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

the class RegionAccessBuilderTest method testAssignmentActionAction.

@Test
public void testAssignmentActionAction() throws Exception {
    String model = "6 (foo) 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 Mixed'foo' Mixed:{AssignedAction.child=} path:AssignedAction/child=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=AssignedAction/child\n" + " 7 1   H \" \"        Whitespace:TerminalRule'WS'\n" + " 8 6   S \"action\"   Mixed:'action'\n" + "      E AssignedAction Mixed:{AssignedAction.child=} path:AssignedAction/child\n" + "14 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "15 6  S \"action\"   Mixed:'action'\n" + "     E AssignedAction Root\n" + "21 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