Search in sources :

Example 21 with Root

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

the class RegionAccessBuilderTest method testAssignedDelegate.

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

Example 22 with Root

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

the class RegionAccessBuilderTest method testAction.

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

Example 23 with Root

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

the class RegionAccessDiffTest method testEmptyModification.

@Test
public void testEmptyModification() throws Exception {
    String model = "1 foo\n";
    ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
    String expectation1 = "0 0 H\n" + "    B Simple'foo' Root\n" + "0 1  S \"1\"        Simple:'1'\n" + "1 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "2 3  S \"foo\"      Simple:name=ID\n" + "    E Simple'foo' Root\n" + "5 0 H\n";
    regionAccessTestHelper.assertRegions(access, expectation1);
    ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
    });
    String expectation2 = "0 0 H\n" + "    B Simple'foo' Root\n" + "0 1  S \"1\"        Simple:'1'\n" + "1 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "2 3  S \"foo\"      Simple:name=ID\n" + "    E Simple'foo' Root\n" + "5 0 H\n";
    regionAccessTestHelper.assertRegions(modifiedAccess, expectation2);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) ITextRegionDiffBuilder(org.eclipse.xtext.formatting2.regionaccess.ITextRegionDiffBuilder) Test(org.junit.Test)

Example 24 with Root

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

the class RegionAccessDiffTest method testMove.

@Test
public void testMove() throws Exception {
    String model = "8 a b c\n";
    ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
    ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
        List<ISemanticRegion> regions = access.regionForRootEObject().getAllRegionsFor().features(RegionaccesstestlanguagePackage.Literals.VALUE_LIST__NAME);
        ISemanticRegion a = regions.get(0);
        ISemanticRegion b = regions.get(1);
        it.move(b.getNextHiddenRegion(), a.getPreviousHiddenRegion(), a.getNextHiddenRegion());
    });
    String expectation = "0 0   H\n" + "      B ValueList'[a, b, c]' Root\n" + "0 1    S \"8\"        Root:'8'\n" + "1   1  H \" \"        Whitespace:TerminalRule'WS'\n" + "  2    \" \"        Whitespace:TerminalRule'WS'\n" + "3 1    S \"b\"        ValueList:name+=ID\n" + "4 1 2  H \" \"        Whitespace:TerminalRule'WS'\n" + "5 1 2  S \"a\"        ValueList:name+=ID\n" + "6 0 2  H\n" + "6 1    S \"c\"        ValueList:name+=ID\n" + "      E ValueList'[a, b, c]' Root\n" + "7 0   H\n" + "------------ diff 1 ------------\n" + "1 1 H \" \"        Whitespace:TerminalRule'WS'\n" + "2 1 S \"a\"        ValueList:name+=ID\n" + "3 1 H \" \"        Whitespace:TerminalRule'WS'\n" + "------------ diff 2 ------------\n" + "5 1 H \" \"        Whitespace:TerminalRule'WS'\n" + "6 1 S \"c\"        ValueList:name+=ID\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 25 with Root

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

the class RegionAccessTestLanguageSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == RegionaccesstestlanguagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case RegionaccesstestlanguagePackage.ACTION:
                sequence_Fragment_Mixed(context, (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Action) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.ADD:
                sequence_Expression(context, (Add) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.ASSIGNED_ACTION:
                sequence_Mixed(context, (AssignedAction) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.DELEGATE:
                sequence_Delegate(context, (Delegate) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.DELEGATION:
                sequence_Delegation(context, (Delegation) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.MIXED:
                sequence_Mixed(context, (Mixed) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.NAMED:
                sequence_Primary(context, (Named) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.PREFIXED_UNASSIGNED:
                sequence_PrefixedUnassigned(context, (PrefixedUnassigned) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.ROOT:
                sequence_Root(context, (Root) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.ROOT_ACTION:
                sequence_Root(context, (RootAction) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.SIMPLE:
                sequence_Simple(context, (Simple) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.VALUE_LIST:
                sequence_ValueList(context, (ValueList) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : Add(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Add) ParserRule(org.eclipse.xtext.ParserRule) Named(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Named) Action(org.eclipse.xtext.Action) RootAction(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.RootAction) AssignedAction(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.AssignedAction) Root(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Root) RootAction(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.RootAction) ValueList(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList) Delegation(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegation) EPackage(org.eclipse.emf.ecore.EPackage) Simple(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Simple) AssignedAction(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.AssignedAction) Delegate(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate) Mixed(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Mixed) Parameter(org.eclipse.xtext.Parameter) PrefixedUnassigned(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.PrefixedUnassigned)

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