use of org.eclipse.xtext.ide.serializer.IChangeSerializer in project xtext-core by eclipse.
the class ChangeSerializerTest method testNoop.
@Test
public void testNoop() {
IChangeSerializer serializer = changeSerializerTestHelper.newChangeSerializer();
Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
changeSerializerTestHelper.operator_tripleEquals(changes, "");
}
use of org.eclipse.xtext.ide.serializer.IChangeSerializer in project xtext-core by eclipse.
the class ChangeSerializerTest method testSimple.
@Test
public void testSimple() {
InMemoryURIHandler fs = new InMemoryURIHandler();
changeSerializerTestHelper.operator_add(fs, Pair.of("inmemory:/file1.pstl", "#2 foo"));
ResourceSet rs = changeSerializerTestHelper.createResourceSet(fs);
MandatoryValue model = changeSerializerTestHelper.findFirstOfTypeInFile(rs, "inmemory:/file1.pstl", MandatoryValue.class);
IChangeSerializer serializer = changeSerializerTestHelper.newChangeSerializer();
serializer.addModification(model.eResource(), (Resource it) -> {
model.setName("bar");
});
Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
String expectation = "----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------\n" + "#2 <3:3|bar>\n" + "--------------------------------------------------------------------------------\n" + "3 3 \"foo\" -> \"bar\"\n";
changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
use of org.eclipse.xtext.ide.serializer.IChangeSerializer 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);
}
use of org.eclipse.xtext.ide.serializer.IChangeSerializer in project xtext-core by eclipse.
the class ChangeSerializerTest method testRenameFqn1.
@Test
public void testRenameFqn1() {
InMemoryURIHandler fs = new InMemoryURIHandler();
String content = "#1 r {\n" + " X refs a1.a2 X.a1.a2 r.X.a1.a2 { a1 { a2 refs a2 { a3 { ref a3 } } } }\n" + " Y refs b1.b2 Y.b1.b2 r.Y.b1.b2 { b1 { b2 { ref b2 } } }\n" + "}\n";
changeSerializerTestHelper.operator_add(fs, Pair.of("inmemory:/file1.pstl", content));
ResourceSet rs = changeSerializerTestHelper.createResourceSet(fs);
Node model = changeSerializerTestHelper.findFirstOfTypeInFile(rs, "inmemory:/file1.pstl", Node.class);
IChangeSerializer serializer = changeSerializerTestHelper.newChangeSerializer();
serializer.addModification(model.eResource(), (Resource it) -> {
Node node = model.getChildren().get(0).getChildren().get(0).getChildren().get(0);
node.setName("b");
});
Assert.assertEquals(1, model.eResource().getResourceSet().getResources().size());
Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
String expectation = "----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------\n" + "#1 r {\n" + " X refs <15:5|a1.b> <21:7|a1.b> <29:9|a1.b> { a1 { <46:2|b> refs <54:2|b> { a3 { ref a3 } } } }\n" + " Y refs b1.b2 Y.b1.b2 r.Y.b1.b2 { b1 { b2 { ref b2 } } }\n" + "}\n" + "--------------------------------------------------------------------------------\n" + "15 5 \"a1.a2\" -> \"a1.b\"\n" + "21 7 \"X.a1.a2\" -> \"a1.b\"\n" + "29 9 \"r.X.a1.a2\" -> \"a1.b\"\n" + "46 2 \"a2\" -> \"b\"\n" + "54 2 \"a2\" -> \"b\"\n";
changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
use of org.eclipse.xtext.ide.serializer.IChangeSerializer 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);
}
Aggregations