Search in sources :

Example 1 with ChildWithSubChild

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

the class ChangeSerializerTest method testAddElements.

@Test
public void testAddElements() {
    String uri = "inmemory:/file-add.pstl";
    InMemoryURIHandler fs = new InMemoryURIHandler();
    changeSerializerTestHelper.operator_add(fs, Pair.of(uri, "#23"));
    ResourceSet rs = changeSerializerTestHelper.createResourceSet(fs);
    ChildWithSubChilds model = changeSerializerTestHelper.findFirstOfTypeInFile(rs, uri, ChildWithSubChilds.class);
    IChangeSerializer serializer = changeSerializerTestHelper.newChangeSerializer();
    serializer.addModification(model.eResource(), (Resource it) -> {
        ChildWithSubChild newChildWithSubChild = fac.createChildWithSubChild();
        SubChild newSubChild1 = fac.createSubChild();
        newSubChild1.setName("A");
        newChildWithSubChild.getSubChilds().add(newSubChild1);
        model.getChildren().add(newChildWithSubChild);
        SubChild newSubChild = fac.createSubChild();
        newSubChild.setName("A2");
        model.getChildren().get(0).getSubChilds().add(newSubChild);
    });
    Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
    String expectation = "--------------- inmemory:/file-add.pstl (syntax: <offset|text>) ----------------\n" + "<0:3|#23 subs A A2>\n" + "--------------------------------------------------------------------------------\n" + "0 3 \"#23\" -> \"#23 subs A A2\"\n";
    changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
Also used : ChildWithSubChild(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.ChildWithSubChild) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) InMemoryURIHandler(org.eclipse.xtext.testing.util.InMemoryURIHandler) Resource(org.eclipse.emf.ecore.resource.Resource) ChildWithSubChild(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.ChildWithSubChild) SubChild(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.SubChild) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ChildWithSubChilds(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.ChildWithSubChilds) IEmfResourceChange(org.eclipse.xtext.ide.serializer.IEmfResourceChange) Test(org.junit.Test)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 IChangeSerializer (org.eclipse.xtext.ide.serializer.IChangeSerializer)1 IEmfResourceChange (org.eclipse.xtext.ide.serializer.IEmfResourceChange)1 ChildWithSubChild (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.ChildWithSubChild)1 ChildWithSubChilds (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.ChildWithSubChilds)1 SubChild (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.SubChild)1 InMemoryURIHandler (org.eclipse.xtext.testing.util.InMemoryURIHandler)1 Test (org.junit.Test)1