use of org.eclipse.xtext.testing.util.InMemoryURIHandler in project xtext-core by eclipse.
the class FileAwareTestLanguageImportTest method testMoveToNewPackage.
@Test
public void testMoveToNewPackage() {
InMemoryURIHandler fs = new InMemoryURIHandler();
String content1 = "package pkg1\n" + "\n" + "element Foo {\n" + "}\n";
importTestHelper.operator_add(fs, Pair.of("inmemory:/file1.fileawaretestlanguage", content1));
String content2 = "package pkg1\n" + "\n" + "element Bar {\n" + " ref Foo\n" + "}\n";
importTestHelper.operator_add(fs, Pair.of("inmemory:/file2.fileawaretestlanguage", content2));
ResourceSet rs = importTestHelper.createResourceSet(fs);
PackageDeclaration model = importTestHelper.contents(rs, "inmemory:/file1.fileawaretestlanguage", PackageDeclaration.class);
ChangeSerializer serializer = serializerProvider.get();
serializer.addModification(model, (PackageDeclaration it) -> {
it.setName("newpackage");
});
Assert.assertEquals(1, model.eResource().getResourceSet().getResources().size());
Collection<IEmfResourceChange> changes = importTestHelper.endRecordChangesToTextDocuments(serializer);
String expectation = "-------- inmemory:/file1.fileawaretestlanguage (syntax: <offset|text>) ---------\n" + "package <8:4|newpackage>\n" + "\n" + "element Foo {\n" + "}\n" + "--------------------------------------------------------------------------------\n" + "8 4 \"pkg1\" -> \"newpackage\"\n" + "-------- inmemory:/file2.fileawaretestlanguage (syntax: <offset|text>) ---------\n" + "package pkg1\n" + "\n" + "<14:0|import newpackage.Foo\n" + "\n" + ">element Bar {\n" + " ref Foo\n" + "}\n" + "--------------------------------------------------------------------------------\n" + "14 0 \"\" -> \"import newpackage...\"\n";
importTestHelper.operator_tripleEquals(changes, expectation);
}
use of org.eclipse.xtext.testing.util.InMemoryURIHandler in project xtext-core by eclipse.
the class FileAwareTestLanguageImportTest method testMoveIntoLocalPackage.
@Test
public void testMoveIntoLocalPackage() {
InMemoryURIHandler fs = new InMemoryURIHandler();
String content1 = "package other\n" + "\n" + "element Foo {\n" + "}\n";
importTestHelper.operator_add(fs, Pair.of("inmemory:/file1.fileawaretestlanguage", content1));
String content2 = "package pkg1\n" + "\n" + "import other.Foo\n" + "\n" + "element Bar {\n" + " ref Foo\n" + "}\n";
importTestHelper.operator_add(fs, Pair.of("inmemory:/file2.fileawaretestlanguage", content2));
ResourceSet rs = importTestHelper.createResourceSet(fs);
PackageDeclaration model = importTestHelper.contents(rs, "inmemory:/file1.fileawaretestlanguage", PackageDeclaration.class);
ChangeSerializer serializer = serializerProvider.get();
serializer.addModification(model, (PackageDeclaration it) -> {
it.setName("pkg1");
});
Assert.assertEquals(1, model.eResource().getResourceSet().getResources().size());
Collection<IEmfResourceChange> changes = importTestHelper.endRecordChangesToTextDocuments(serializer);
String expectation = "-------- inmemory:/file1.fileawaretestlanguage (syntax: <offset|text>) ---------\n" + "package <8:5|pkg1>\n" + "\n" + "element Foo {\n" + "}\n" + "--------------------------------------------------------------------------------\n" + "8 5 \"other\" -> \"pkg1\"\n" + "-------- inmemory:/file2.fileawaretestlanguage (syntax: <offset|text>) ---------\n" + "package pkg1\n" + "\n" + "<14:18|>element Bar {\n" + " ref Foo\n" + "}\n" + "--------------------------------------------------------------------------------\n" + "14 18 \"import other.Foo\\n" + "\\n" + "\" -> \"\"\n";
importTestHelper.operator_tripleEquals(changes, expectation);
}
Aggregations