use of org.eclipse.xtext.ide.serializer.IEmfResourceChange in project xtext-core by eclipse.
the class TextDocumentChangeToString method toString.
@Override
public String toString() {
List<String> result = Lists.newArrayList();
for (IEmfResourceChange c : changes) {
String title = getTitle(c);
if (c instanceof ITextDocumentChange) {
ITextDocumentChange change = (ITextDocumentChange) c;
TextRegionsToString textRegionsToString = new TextRegionsToString();
textRegionsToString.setIgnoreCarriageReturnInQuotes(true);
textRegionsToString.addAllReplacements(change.getReplacements());
textRegionsToString.setTitle(title);
result.add(textRegionsToString.toString());
} else {
String box = box(title, c.toString());
result.add(box);
}
}
return Joiner.on("\n").join(result);
}
use of org.eclipse.xtext.ide.serializer.IEmfResourceChange in project xtext-core by eclipse.
the class RecordingEmfResourceUpdater method applyChange.
@Override
public void applyChange(Deltas deltas, IAcceptor<IEmfResourceChange> changeAcceptor) {
EmfResourceChange change = new EmfResourceChange(snapshot.getResource(), snapshot.getURI());
changeAcceptor.accept(change);
}
use of org.eclipse.xtext.ide.serializer.IEmfResourceChange in project xtext-core by eclipse.
the class FileAwareTestLanguageImportTest method testMoveToNewPackage.
@Test
public void testMoveToNewPackage() {
final InMemoryURIHandler fs = new InMemoryURIHandler();
StringConcatenation _builder = new StringConcatenation();
_builder.append("package pkg1");
_builder.newLine();
_builder.newLine();
_builder.append("element Foo {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/file1.fileawaretestlanguage", _builder.toString());
this._importTestHelper.operator_add(fs, _mappedTo);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package pkg1");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("element Bar {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("ref Foo");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
Pair<String, String> _mappedTo_1 = Pair.<String, String>of("inmemory:/file2.fileawaretestlanguage", _builder_1.toString());
this._importTestHelper.operator_add(fs, _mappedTo_1);
final ResourceSet rs = this._importTestHelper.createResourceSet(fs);
final PackageDeclaration model = this._importTestHelper.<PackageDeclaration>contents(rs, "inmemory:/file1.fileawaretestlanguage", PackageDeclaration.class);
final ChangeSerializer serializer = this.serializerProvider.get();
final IChangeSerializer.IModification<PackageDeclaration> _function = (PackageDeclaration it) -> {
model.setName("newpackage");
};
serializer.<PackageDeclaration>addModification(model, _function);
Assert.assertEquals(1, model.eResource().getResourceSet().getResources().size());
Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._importTestHelper.endRecordChangesToTextDocuments(serializer);
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("-------- inmemory:/file1.fileawaretestlanguage (syntax: <offset|text>) ---------");
_builder_2.newLine();
_builder_2.append("package <8:4|newpackage>");
_builder_2.newLine();
_builder_2.newLine();
_builder_2.append("element Foo {");
_builder_2.newLine();
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("--------------------------------------------------------------------------------");
_builder_2.newLine();
_builder_2.append("8 4 \"pkg1\" -> \"newpackage\"");
_builder_2.newLine();
_builder_2.append("-------- inmemory:/file2.fileawaretestlanguage (syntax: <offset|text>) ---------");
_builder_2.newLine();
_builder_2.append("package pkg1");
_builder_2.newLine();
_builder_2.newLine();
_builder_2.append("<14:0|import newpackage.Foo");
_builder_2.newLine();
_builder_2.newLine();
_builder_2.append(">element Bar {");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("ref Foo");
_builder_2.newLine();
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("--------------------------------------------------------------------------------");
_builder_2.newLine();
_builder_2.append("14 0 \"\" -> \"import newpackage...\"");
_builder_2.newLine();
this._importTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_2);
}
use of org.eclipse.xtext.ide.serializer.IEmfResourceChange in project xtext-core by eclipse.
the class FileAwareTestLanguageImportTest method testMoveIntoLocalPackage.
@Test
public void testMoveIntoLocalPackage() {
final InMemoryURIHandler fs = new InMemoryURIHandler();
StringConcatenation _builder = new StringConcatenation();
_builder.append("package other");
_builder.newLine();
_builder.newLine();
_builder.append("element Foo {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/file1.fileawaretestlanguage", _builder.toString());
this._importTestHelper.operator_add(fs, _mappedTo);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package pkg1");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("import other.Foo");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("element Bar {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("ref Foo");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
Pair<String, String> _mappedTo_1 = Pair.<String, String>of("inmemory:/file2.fileawaretestlanguage", _builder_1.toString());
this._importTestHelper.operator_add(fs, _mappedTo_1);
final ResourceSet rs = this._importTestHelper.createResourceSet(fs);
final PackageDeclaration model = this._importTestHelper.<PackageDeclaration>contents(rs, "inmemory:/file1.fileawaretestlanguage", PackageDeclaration.class);
final ChangeSerializer serializer = this.serializerProvider.get();
final IChangeSerializer.IModification<PackageDeclaration> _function = (PackageDeclaration it) -> {
model.setName("pkg1");
};
serializer.<PackageDeclaration>addModification(model, _function);
Assert.assertEquals(1, model.eResource().getResourceSet().getResources().size());
Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._importTestHelper.endRecordChangesToTextDocuments(serializer);
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("-------- inmemory:/file1.fileawaretestlanguage (syntax: <offset|text>) ---------");
_builder_2.newLine();
_builder_2.append("package <8:5|pkg1>");
_builder_2.newLine();
_builder_2.newLine();
_builder_2.append("element Foo {");
_builder_2.newLine();
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("--------------------------------------------------------------------------------");
_builder_2.newLine();
_builder_2.append("8 5 \"other\" -> \"pkg1\"");
_builder_2.newLine();
_builder_2.append("-------- inmemory:/file2.fileawaretestlanguage (syntax: <offset|text>) ---------");
_builder_2.newLine();
_builder_2.append("package pkg1");
_builder_2.newLine();
_builder_2.newLine();
_builder_2.append("<14:18|>element Bar {");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("ref Foo");
_builder_2.newLine();
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("--------------------------------------------------------------------------------");
_builder_2.newLine();
_builder_2.append("14 18 \"import other.Foo\\n\\n\" -> \"\"");
_builder_2.newLine();
this._importTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_2);
}
use of org.eclipse.xtext.ide.serializer.IEmfResourceChange in project xtext-core by eclipse.
the class ChangeSerializerTest method testResourceURIChange.
@Test
public void testResourceURIChange() {
final InMemoryURIHandler fs = new InMemoryURIHandler();
StringConcatenation _builder = new StringConcatenation();
_builder.append("#1 root { }");
Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/f.pstl", _builder.toString());
this._changeSerializerTestHelper.operator_add(fs, _mappedTo);
final ResourceSet rs = this._changeSerializerTestHelper.createResourceSet(fs);
final Node model = this._changeSerializerTestHelper.<Node>contents(rs, "inmemory:/f.pstl", Node.class);
final IChangeSerializer serializer = this._changeSerializerTestHelper.newChangeSerializer();
final IChangeSerializer.IModification<Resource> _function = (Resource it) -> {
Resource _eResource = model.eResource();
_eResource.setURI(URI.createURI("inmemory:/x.pstl"));
};
serializer.<Resource>addModification(model.eResource(), _function);
Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("----- renamed inmemory:/f.pstl to inmemory:/x.pstl (syntax: <offset|text>) -----");
_builder_1.newLine();
_builder_1.append("(no changes)");
_builder_1.newLine();
_builder_1.append("--------------------------------------------------------------------------------");
_builder_1.newLine();
this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_1);
}
Aggregations