Search in sources :

Example 16 with MandatoryValue

use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue in project xtext-core by eclipse.

the class PartialSerializerTest method testOptionalChildListInsertIntoFirst.

@Test
public void testOptionalChildListInsertIntoFirst() {
    ITextRegionAccess diff = recordDiff(OptionalChildList.class, "#13 x2", (OptionalChildList it) -> {
        MandatoryValue newMandatoryValue = fac.createMandatoryValue();
        newMandatoryValue.setName("x1");
        it.getChildren().add(0, newMandatoryValue);
    });
    String expectation = "0 0   H\n" + "      B OptionalChildList    Model\n" + "0 3    S \"#13\"                Model:'#13'\n" + "3 1 1  H \" \"                  Whitespace:TerminalRule'WS'\n" + "       B MandatoryValue'x1'   MandatoryValue path:OptionalChildList/children[0]\n" + "4 2 1   S \"x1\"                 MandatoryValue:name=ID\n" + "       E MandatoryValue'x1'   MandatoryValue path:OptionalChildList/children[0]\n" + "6 0 1  H\n" + "       B MandatoryValue'x2'   OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[1]\n" + "6 2     S \"x2\"                 MandatoryValue:name=ID\n" + "       E MandatoryValue'x2'   OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[1]\n" + "      E OptionalChildList    Model\n" + "8 0   H\n" + "------------ diff 1 ------------\n" + "3 1 H \" \"                  Whitespace:TerminalRule'WS'\n" + "4 2 S \"x2\"                 MandatoryValue:name=ID\n";
    changeSerializerTestHelper.operator_tripleEquals(diff, expectation);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) OptionalChildList(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChildList) MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) Test(org.junit.Test)

Example 17 with MandatoryValue

use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue in project xtext-core by eclipse.

the class PartialSerializerTest method testOptionalChildListInsertIntoEmpty.

@Test
public void testOptionalChildListInsertIntoEmpty() {
    ITextRegionAccess diff = recordDiff(OptionalChildList.class, "#13", (OptionalChildList it) -> {
        MandatoryValue newMandatoryValue = fac.createMandatoryValue();
        newMandatoryValue.setName("foo");
        it.getChildren().add(newMandatoryValue);
    });
    String expectation = "0 0   H\n" + "      B OptionalChildList    Model\n" + "0 3 1  S \"#13\"                Model:'#13'\n" + "3 0 1  H\n" + "       B MandatoryValue'foo'  MandatoryValue path:OptionalChildList/children[0]\n" + "3 3 1   S \"foo\"                MandatoryValue:name=ID\n" + "       E MandatoryValue'foo'  MandatoryValue path:OptionalChildList/children[0]\n" + "      E OptionalChildList    Model\n" + "6 0 1 H\n" + "------------ diff 1 ------------\n" + "0 3  S \"#13\"                Model:'#13'\n" + "3 0  H\n";
    changeSerializerTestHelper.operator_tripleEquals(diff, expectation);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) OptionalChildList(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChildList) MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) Test(org.junit.Test)

Example 18 with MandatoryValue

use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue in project xtext-core by eclipse.

the class OptionalChildImpl method basicSetChild.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetChild(MandatoryValue newChild, NotificationChain msgs) {
    MandatoryValue oldChild = child;
    child = newChild;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PartialSerializationTestLanguagePackage.OPTIONAL_CHILD__CHILD, oldChild, newChild);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 19 with MandatoryValue

use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue in project xtext-core by eclipse.

the class TwoChildsImpl method basicSetDirectChild.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetDirectChild(MandatoryValue newDirectChild, NotificationChain msgs) {
    MandatoryValue oldDirectChild = directChild;
    directChild = newDirectChild;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PartialSerializationTestLanguagePackage.TWO_CHILDS__DIRECT_CHILD, oldDirectChild, newDirectChild);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

MandatoryValue (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue)19 Test (org.junit.Test)16 ITextRegionAccess (org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess)11 OptionalChildList (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChildList)7 Resource (org.eclipse.emf.ecore.resource.Resource)5 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)5 IChangeSerializer (org.eclipse.xtext.ide.serializer.IChangeSerializer)5 IEmfResourceChange (org.eclipse.xtext.ide.serializer.IEmfResourceChange)5 InMemoryURIHandler (org.eclipse.xtext.testing.util.InMemoryURIHandler)5 TwoChildLists (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.TwoChildLists)4 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)3 OptionalChild (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChild)2 MandatoryChild (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryChild)1