Search in sources :

Example 6 with ValueList

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList 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)

Example 7 with ValueList

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

the class RegionAccessBuilderTest method testComments1.

@Test
public void testComments1() throws Exception {
    String model = "/*xxxx*/\n" + "8\n" + "/*aaaaa*/\n" + "c\n" + "// last\n".trim();
    String expectation = " 0    H \"/*xxxx*/\" Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + "    9   \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + "      B ValueList'[c]' Root\n" + " 9  1  S \"8\"        Root:'8'\n" + "10     H \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + "         \"/*aaa...\" Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + "   11    \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + "21  1  S \"c\"        ValueList:name+=ID\n" + "      E ValueList'[c]' Root\n" + "22    H \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + "    8   \"// last\"  Comment:TerminalRule'SL_COMMENT' Association:CONTAINER\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 8 with ValueList

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

the class RegionAccessDiffTest method testInsertReplaceReplace.

@Test
public void testInsertReplaceReplace() throws Exception {
    String model = "8 a\n";
    ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
    ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
        ITextRegionExtensions ext = access.getExtensions();
        ValueList rootObj = (ValueList) access.regionForRootEObject().getSemanticElement();
        ISemanticRegion a = ext.regionFor(rootObj).keyword("8").getNextSemanticRegion();
        it.replace(a, "b");
        it.replace(a, "c");
    });
    String expectation = "0 0   H\n" + "      B ValueList'[a]' Root\n" + "0 1    S \"8\"        Root:'8'\n" + "1 1    H \" \"        Whitespace:TerminalRule'WS'\n" + "2 1 1  S \"c\"        ValueList:name+=ID\n" + "      E ValueList'[a]' Root\n" + "3 0   H\n" + "------------ diff 1 ------------\n" + "2 1 S \"a\"        ValueList:name+=ID\n";
    regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) ValueList(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList) 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)

Example 9 with ValueList

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

the class RegionAccessDiffTest method testInsertInsertReplace.

@Test
public void testInsertInsertReplace() throws Exception {
    String model = "8 a\n";
    ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
    ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
        ITextRegionExtensions ext = access.getExtensions();
        ValueList rootObj = (ValueList) access.regionForRootEObject().getSemanticElement();
        ISemanticRegion a = ext.regionFor(rootObj).keyword("8").getNextSemanticRegion();
        it.replace(a.getNextHiddenRegion(), a.getNextHiddenRegion(), a.getPreviousHiddenRegion(), a.getNextHiddenRegion());
        it.replace(a.getNextHiddenRegion(), a.getNextHiddenRegion(), a.getPreviousHiddenRegion(), a.getNextHiddenRegion());
        it.replace(a, "new");
    });
    String expectation = " 0 0   H\n" + "       B ValueList'[a]' Root\n" + " 0 1    S \"8\"        Root:'8'\n" + " 1 1    H \" \"        Whitespace:TerminalRule'WS'\n" + " 2 3 2  S \"new\"      ValueList:name+=ID\n" + " 5 0 2  H\n" + " 5 3 2  S \"new\"      ValueList:name+=ID\n" + " 8 0 2  H\n" + " 8 3 2  S \"new\"      ValueList:name+=ID\n" + "       E ValueList'[a]' Root\n" + "11 0 2 H\n" + "------------ diff 1 ------------\n" + " 2 1 S \"a\"        ValueList:name+=ID\n" + "------------ diff 2 ------------\n" + " 2 1  S \"a\"        ValueList:name+=ID\n" + " 3 0  H\n";
    regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) ValueList(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList) 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)

Example 10 with ValueList

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

the class RegionAccessDiffTest method testInsertBeforeComment.

@Test
public void testInsertBeforeComment() throws Exception {
    String model = "8\n" + "/**/\n" + "a b\n";
    ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
    ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
        ITextRegionExtensions ext = access.getExtensions();
        ValueList rootObj = (ValueList) access.regionForRootEObject().getSemanticElement();
        ISemanticRegion a = ext.regionFor(rootObj).keyword("8").getNextSemanticRegion();
        ISemanticRegion b = a.getNextSemanticRegion();
        it.replace(a.getPreviousHiddenRegion(), a.getPreviousHiddenRegion(), b.getPreviousHiddenRegion(), b.getNextHiddenRegion());
    });
    String expectation = " 0 0   H\n" + "       B ValueList'[a, b]' Root\n" + " 0 1    S \"8\"        Root:'8'\n" + " 1 1 1  H \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + " 2 1 1  S \"b\"        ValueList:name+=ID\n" + " 3   1  H \"/**/\"     Comment:TerminalRule'ML_COMMENT' Association:PREVIOUS\n" + "   5    \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + " 8 1    S \"a\"        ValueList:name+=ID\n" + " 9 1    H \" \"        Whitespace:TerminalRule'WS'\n" + "10 1    S \"b\"        ValueList:name+=ID\n" + "       E ValueList'[a, b]' Root\n" + "11 0   H\n" + "------------ diff 1 ------------\n" + " 1   H \"\\n" + "\"       Whitespace:TerminalRule'WS'\n" + "       \"/**/\"     Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + "   6   \"\\n" + "\"       Whitespace:TerminalRule'WS'\n";
    regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) ValueList(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList) 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)11 ISemanticRegion (org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion)10 ITextRegionAccess (org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess)10 ITextRegionDiffBuilder (org.eclipse.xtext.formatting2.regionaccess.ITextRegionDiffBuilder)10 ValueList (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList)4 ITextRegionExtensions (org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions)3 EPackage (org.eclipse.emf.ecore.EPackage)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 TextRegionAccessToString (org.eclipse.xtext.formatting2.debug.TextRegionAccessToString)1 Add (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Add)1 AssignedAction (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.AssignedAction)1 Delegate (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate)1 Delegation (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegation)1 Mixed (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Mixed)1 Named (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Named)1 PrefixedUnassigned (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.PrefixedUnassigned)1 Root (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Root)1 RootAction (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.RootAction)1