Search in sources :

Example 1 with TwoChildLists

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

the class ChangeSerializerTest method testMoveElement_2.

@Test
public void testMoveElement_2() {
    InMemoryURIHandler fs = new InMemoryURIHandler();
    String content = "#22 {\n" + "	child1\n" + "	children1 {\n" + "		child2 jumper\n" + "	}\n" + "}";
    changeSerializerTestHelper.operator_add(fs, Pair.of("inmemory:/file-move.pstl", content));
    ResourceSet rs = changeSerializerTestHelper.createResourceSet(fs);
    TwoChildLists model = changeSerializerTestHelper.findFirstOfTypeInFile(rs, "inmemory:/file-move.pstl", TwoChildLists.class);
    IChangeSerializer serializer = changeSerializerTestHelper.newChangeSerializer();
    serializer.addModification(model.eResource(), (Resource it) -> {
        model.getDirectChildren().add(0, IterableExtensions.findFirst(model.getChildsList().getChildren(), (MandatoryValue v) -> "jumper".equals(v.getName())));
    });
    Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
    String expectation = "--------------- inmemory:/file-move.pstl (syntax: <offset|text>) ---------------\n" + "#22 {<5:0| jumper>\n" + "	child1\n" + "	children1 {\n" + "		child2 <36:6|>\n" + "	}\n" + "}\n" + "--------------------------------------------------------------------------------\n" + " 5 0 \"\" -> \" jumper\"\n" + "36 6 \"jumper\" -> \"\"\n";
    changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
Also used : MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) InMemoryURIHandler(org.eclipse.xtext.testing.util.InMemoryURIHandler) TwoChildLists(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.TwoChildLists) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IEmfResourceChange(org.eclipse.xtext.ide.serializer.IEmfResourceChange) Test(org.junit.Test)

Example 2 with TwoChildLists

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

the class ChangeSerializerTest method testMoveElement_2a.

@Test
public void testMoveElement_2a() {
    InMemoryURIHandler fs = new InMemoryURIHandler();
    String content = "#22 {\n" + "	child1 child3\n" + "	children1 {\n" + "		child2 jumper\n" + "	}\n" + "}";
    changeSerializerTestHelper.operator_add(fs, Pair.of("inmemory:/file-move2a.pstl", content));
    ResourceSet rs = changeSerializerTestHelper.createResourceSet(fs);
    TwoChildLists model = changeSerializerTestHelper.findFirstOfTypeInFile(rs, "inmemory:/file-move2a.pstl", TwoChildLists.class);
    IChangeSerializer serializer = changeSerializerTestHelper.newChangeSerializer();
    serializer.addModification(model.eResource(), (Resource it) -> {
        model.getDirectChildren().add(1, IterableExtensions.findFirst(model.getChildsList().getChildren(), (MandatoryValue v) -> "jumper".equals(v.getName())));
    });
    Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
    String expectation = "-------------- inmemory:/file-move2a.pstl (syntax: <offset|text>) --------------\n" + "#22 {\n" + "	child1 <14:0|jumper >child3\n" + "	children1 {\n" + "		child2 <43:6|>\n" + "	}\n" + "}\n" + "--------------------------------------------------------------------------------\n" + "14 0 \"\" -> \"jumper \"\n" + "43 6 \"jumper\" -> \"\"\n";
    changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
Also used : MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) InMemoryURIHandler(org.eclipse.xtext.testing.util.InMemoryURIHandler) TwoChildLists(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.TwoChildLists) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IEmfResourceChange(org.eclipse.xtext.ide.serializer.IEmfResourceChange) Test(org.junit.Test)

Example 3 with TwoChildLists

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

the class ChangeSerializerTest method testAddChildElement.

@Test
public void testAddChildElement() {
    InMemoryURIHandler fs = new InMemoryURIHandler();
    String content = "#22 {\n" + "	child1\n" + "	children1 {\n" + "		child2 child3\n" + "	}\n" + "}";
    changeSerializerTestHelper.operator_add(fs, Pair.of("inmemory:/file-move.pstl", content));
    ResourceSet rs = changeSerializerTestHelper.createResourceSet(fs);
    TwoChildLists model = changeSerializerTestHelper.findFirstOfTypeInFile(rs, "inmemory:/file-move.pstl", TwoChildLists.class);
    IChangeSerializer serializer = changeSerializerTestHelper.newChangeSerializer();
    serializer.addModification(model.eResource(), (Resource it) -> {
        MandatoryValue newMandatoryValue = fac.createMandatoryValue();
        newMandatoryValue.setName("newChild");
        model.getDirectChildren().add(newMandatoryValue);
    });
    Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
    String expectation = "--------------- inmemory:/file-move.pstl (syntax: <offset|text>) ---------------\n" + "#22 {\n" + "	child1<13:0| newChild>\n" + "	children1 {\n" + "		child2 child3\n" + "	}\n" + "}\n" + "--------------------------------------------------------------------------------\n" + "13 0 \"\" -> \" newChild\"\n";
    changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
Also used : MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) InMemoryURIHandler(org.eclipse.xtext.testing.util.InMemoryURIHandler) TwoChildLists(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.TwoChildLists) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IEmfResourceChange(org.eclipse.xtext.ide.serializer.IEmfResourceChange) Test(org.junit.Test)

Example 4 with TwoChildLists

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

the class ChangeSerializerTest method testMoveElement.

@Test
public void testMoveElement() {
    InMemoryURIHandler fs = new InMemoryURIHandler();
    String content = "#22 {\n" + "	child1\n" + "	children1 {\n" + "		child2 jumper\n" + "	}\n" + "}";
    changeSerializerTestHelper.operator_add(fs, Pair.of("inmemory:/file-move1.pstl", content));
    ResourceSet rs = changeSerializerTestHelper.createResourceSet(fs);
    TwoChildLists model = changeSerializerTestHelper.findFirstOfTypeInFile(rs, "inmemory:/file-move1.pstl", TwoChildLists.class);
    IChangeSerializer serializer = changeSerializerTestHelper.newChangeSerializer();
    serializer.addModification(model.eResource(), (Resource it) -> {
        model.getDirectChildren().add(IterableExtensions.findFirst(model.getChildsList().getChildren(), (MandatoryValue v) -> "jumper".equals(v.getName())));
    });
    Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
    String expectation = "-------------- inmemory:/file-move1.pstl (syntax: <offset|text>) ---------------\n" + "#22 {\n" + "	child1<13:0| jumper>\n" + "	children1 {\n" + "		child2 <36:6|>\n" + "	}\n" + "}\n" + "--------------------------------------------------------------------------------\n" + "13 0 \"\" -> \" jumper\"\n" + "36 6 \"jumper\" -> \"\"\n";
    changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
Also used : MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) InMemoryURIHandler(org.eclipse.xtext.testing.util.InMemoryURIHandler) TwoChildLists(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.TwoChildLists) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IEmfResourceChange(org.eclipse.xtext.ide.serializer.IEmfResourceChange) Test(org.junit.Test)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)4 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)4 IChangeSerializer (org.eclipse.xtext.ide.serializer.IChangeSerializer)4 IEmfResourceChange (org.eclipse.xtext.ide.serializer.IEmfResourceChange)4 MandatoryValue (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue)4 TwoChildLists (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.TwoChildLists)4 InMemoryURIHandler (org.eclipse.xtext.testing.util.InMemoryURIHandler)4 Test (org.junit.Test)4