use of org.eclipse.xtext.testing.util.InMemoryURIHandler in project xtext-core by eclipse.
the class ChangeSerializerTest method testInsertOneChild.
@Test
public void testInsertOneChild() {
InMemoryURIHandler fs = new InMemoryURIHandler();
changeSerializerTestHelper.operator_add(fs, Pair.of("inmemory:/file1.pstl", "#1 root { child1 { foo1; } }"));
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 newNode = fac.createNode();
newNode.setName("bazz");
model.getChildren().get(0).getChildren().add(newNode);
});
Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
String expectation = "----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------\n" + "#1 root { child1 { foo1; <25:0|bazz; >} }\n" + "--------------------------------------------------------------------------------\n" + "25 0 \"\" -> \"bazz; \"\n";
changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
use of org.eclipse.xtext.testing.util.InMemoryURIHandler in project xtext-core by eclipse.
the class ChangeSerializerTest method testDeleteTwoChildren.
@Test
public void testDeleteTwoChildren() {
InMemoryURIHandler fs = new InMemoryURIHandler();
changeSerializerTestHelper.operator_add(fs, Pair.of("inmemory:/file1.pstl", "#1 root { child1; child2; }"));
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) -> {
EcoreUtil.remove(model.getChildren().get(1));
EcoreUtil.remove(model.getChildren().get(0));
});
Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
String expectation = "----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------\n" + "#1 root { <10:7|> <18:7|> }\n" + "--------------------------------------------------------------------------------\n" + "10 7 \"child1;\" -> \"\"\n" + "18 7 \"child2;\" -> \"\"\n";
changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
use of org.eclipse.xtext.testing.util.InMemoryURIHandler in project xtext-core by eclipse.
the class ChangeSerializerTest method testRenameFqn1ValueConversion.
@Test
public void testRenameFqn1ValueConversion() {
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:7|a1.b> <23:10|a1.b> <34:13|a1.b> { a1 { <55:2|b> refs <63:3|b> { a3 { ref ^a3 } } } }\n" + " Y refs ^b1.^b2 ^Y.^b1.^b2 ^r.^Y.^b1.^b2 { b1 { b2 { ref b2 } } }\n" + "}\n" + "--------------------------------------------------------------------------------\n" + "15 7 \"^a1.^a2\" -> \"a1.b\"\n" + "23 10 \"^X.^a1.^a2\" -> \"a1.b\"\n" + "34 13 \"^r.^X.^a1.^a2\" -> \"a1.b\"\n" + "55 2 \"a2\" -> \"b\"\n" + "63 3 \"^a2\" -> \"b\"\n";
changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
use of org.eclipse.xtext.testing.util.InMemoryURIHandler in project xtext-core by eclipse.
the class ChangeSerializerTest method testTwoChildren.
@Test
public void testTwoChildren() {
InMemoryURIHandler fs = new InMemoryURIHandler();
changeSerializerTestHelper.operator_add(fs, Pair.of("inmemory:/file1.pstl", "#1 root { foo1; foo2; }"));
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) -> {
model.getChildren().get(0).setName("bazz4");
model.getChildren().get(1).setName("bazz5");
});
Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
String expectation = "----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------\n" + "#1 root { <10:4|bazz4>; <16:4|bazz5>; }\n" + "--------------------------------------------------------------------------------\n" + "10 4 \"foo1\" -> \"bazz4\"\n" + "16 4 \"foo2\" -> \"bazz5\"\n";
changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
use of org.eclipse.xtext.testing.util.InMemoryURIHandler in project xtext-core by eclipse.
the class ChangeSerializerTest method testDeleteChild.
@Test
public void testDeleteChild() {
InMemoryURIHandler fs = new InMemoryURIHandler();
changeSerializerTestHelper.operator_add(fs, Pair.of("inmemory:/file1.pstl", "#1 root { child1 { foo1; } }"));
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) -> {
EcoreUtil.remove(model.getChildren().get(0).getChildren().get(0));
});
Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
String expectation = "----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------\n" + "#1 root { child1 { <19:5|> } }\n" + "--------------------------------------------------------------------------------\n" + "19 5 \"foo1;\" -> \"\"\n";
changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
Aggregations