Search in sources :

Example 31 with Root

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

the class RegionAccessBuilderTest method testAssignedDatatype.

@Test
public void testAssignedDatatype() throws Exception {
    String model = "6 (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 12  S \"datat...\" Mixed:datatype=Datatype\n" + "15  0  H\n" + "15  1  S \")\"        Mixed:')'\n" + "      E Mixed      Root\n" + "16  0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 32 with Root

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

the class RegionAccessBuilderTest method testFragmentRecursionID.

@Test
public void testFragmentRecursionID() throws Exception {
    String model = "6 (fragment recursion foo)\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 3  S \"foo\"      Fragment:fragName=ID\n" + "25 0  H\n" + "25 1  S \")\"        Mixed:')'\n" + "     E Action     Root\n" + "26 0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 33 with Root

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

the class RegionAccessBuilderTest method testMultiWhitespace1.

@Test
public void testMultiWhitespace1() throws Exception {
    String model = "1 /**/ foo\n".trim();
    String expectation = " 0 0 H\n" + "     B Simple'foo' Root\n" + " 0 1  S \"1\"        Simple:'1'\n" + " 1    H \" \"        Whitespace:TerminalRule'WS'\n" + "        \"/**/\"     Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "   6    \" \"        Whitespace:TerminalRule'WS'\n" + " 7 3  S \"foo\"      Simple:name=ID\n" + "     E Simple'foo' Root\n" + "10 0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 34 with Root

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

the class RegionAccessBuilderTest method testEnum.

@Test
public void testEnum() throws Exception {
    String model = "6 (lit1)\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 4  S \"lit1\"     Mixed:lit=Enum\n" + "7 0  H\n" + "7 1  S \")\"        Mixed:')'\n" + "    E Mixed      Root\n" + "8 0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 35 with Root

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

the class RegionAccessDiffTest method testDeleteOne.

@Test
public void testDeleteOne() throws Exception {
    String model = "4/*1*/prefix/*2*/foo\n";
    ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
    ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
        ITextRegionExtensions ext = access.getExtensions();
        PrefixedUnassigned rootObj = (PrefixedUnassigned) access.regionForRootEObject().getSemanticElement();
        ISemanticRegion prefix = ext.regionFor(rootObj.getDelegate()).keyword("prefix");
        it.remove(prefix);
    });
    String expectation = " 0  0   H\n" + "        B PrefixedUnassigned Root\n" + " 0  1    S \"4\"        PrefixedUnassigned:'4'\n" + " 1    1  H \"/*1*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "   10    \"/*2*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "         B Delegate'foo' PrefixedUnassigned:delegate=PrefixedDelegate path:PrefixedUnassigned/delegate\n" + "11  3     S \"foo\"      Delegate:name=ID\n" + "         E Delegate'foo' PrefixedUnassigned:delegate=PrefixedDelegate path:PrefixedUnassigned/delegate\n" + "        E PrefixedUnassigned Root\n" + "14  0   H\n" + "------------ diff 1 ------------\n" + " 1  5 H \"/*1*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + " 6  6 S \"prefix\"   PrefixedDelegate:'prefix'\n" + "12  5 H \"/*2*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n";
    regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) PrefixedUnassigned(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.PrefixedUnassigned) ITextRegionDiffBuilder(org.eclipse.xtext.formatting2.regionaccess.ITextRegionDiffBuilder) ISemanticRegion(org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion) ITextRegionExtensions(org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions) 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