use of org.eclipse.xtext.ide.serializer.IEmfResourceChange in project xtext-core by eclipse.
the class RelatedEmfResourceUpdater method applyChange.
@Override
public void applyChange(Deltas deltas, IAcceptor<IEmfResourceChange> changeAcceptor) {
Resource res = lifecycleManager.openAndApplyReferences(getResourceSet(), getResource());
EmfResourceChange change = new EmfResourceChange(res, res.getURI());
changeAcceptor.accept(change);
}
use of org.eclipse.xtext.ide.serializer.IEmfResourceChange in project xtext-core by eclipse.
the class ChangeSerializerTest method testNoop.
@Test
public void testNoop() {
final IChangeSerializer serializer = this._changeSerializerTestHelper.newChangeSerializer();
Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, "");
}
use of org.eclipse.xtext.ide.serializer.IEmfResourceChange in project xtext-core by eclipse.
the class ChangeSerializerTest method testRenameGlobal1.
@Test
public void testRenameGlobal1() {
final InMemoryURIHandler fs = new InMemoryURIHandler();
StringConcatenation _builder = new StringConcatenation();
_builder.append("#1 root1;");
Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/file1.pstl", _builder.toString());
this._changeSerializerTestHelper.operator_add(fs, _mappedTo);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("#1 root2 { ref root1 }");
Pair<String, String> _mappedTo_1 = Pair.<String, String>of("inmemory:/file2.pstl", _builder_1.toString());
this._changeSerializerTestHelper.operator_add(fs, _mappedTo_1);
final ResourceSet rs = this._changeSerializerTestHelper.createResourceSet(fs);
final Node model = this._changeSerializerTestHelper.<Node>contents(rs, "inmemory:/file1.pstl", Node.class);
final IChangeSerializer serializer = this._changeSerializerTestHelper.newChangeSerializer();
final IChangeSerializer.IModification<Resource> _function = (Resource it) -> {
model.setName("newroot");
};
serializer.<Resource>addModification(model.eResource(), _function);
Assert.assertEquals(1, model.eResource().getResourceSet().getResources().size());
Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------");
_builder_2.newLine();
_builder_2.append("#1 <3:5|newroot>;");
_builder_2.newLine();
_builder_2.append("--------------------------------------------------------------------------------");
_builder_2.newLine();
_builder_2.append("3 5 \"root1\" -> \"newroot\"");
_builder_2.newLine();
_builder_2.append("----------------- inmemory:/file2.pstl (syntax: <offset|text>) -----------------");
_builder_2.newLine();
_builder_2.append("#1 root2 { ref <15:5|newroot> }");
_builder_2.newLine();
_builder_2.append("--------------------------------------------------------------------------------");
_builder_2.newLine();
_builder_2.append("15 5 \"root1\" -> \"newroot\"");
_builder_2.newLine();
this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_2);
}
use of org.eclipse.xtext.ide.serializer.IEmfResourceChange in project xtext-core by eclipse.
the class ChangeSerializerTest method testSimple.
@Test
public void testSimple() {
final InMemoryURIHandler fs = new InMemoryURIHandler();
StringConcatenation _builder = new StringConcatenation();
_builder.append("#2 foo");
Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/file1.pstl", _builder.toString());
this._changeSerializerTestHelper.operator_add(fs, _mappedTo);
final ResourceSet rs = this._changeSerializerTestHelper.createResourceSet(fs);
final MandatoryValue model = this._changeSerializerTestHelper.<MandatoryValue>contents(rs, "inmemory:/file1.pstl", MandatoryValue.class);
final IChangeSerializer serializer = this._changeSerializerTestHelper.newChangeSerializer();
final IChangeSerializer.IModification<Resource> _function = (Resource it) -> {
model.setName("bar");
};
serializer.<Resource>addModification(model.eResource(), _function);
Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------");
_builder_1.newLine();
_builder_1.append("#2 <3:3|bar>");
_builder_1.newLine();
_builder_1.append("--------------------------------------------------------------------------------");
_builder_1.newLine();
_builder_1.append("3 3 \"foo\" -> \"bar\"");
_builder_1.newLine();
this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_1);
}
use of org.eclipse.xtext.ide.serializer.IEmfResourceChange in project xtext-core by eclipse.
the class ChangeSerializerTest method testRenameFqn1.
@Test
public void testRenameFqn1() {
final InMemoryURIHandler fs = new InMemoryURIHandler();
StringConcatenation _builder = new StringConcatenation();
_builder.append("#1 r {");
_builder.newLine();
_builder.append("\t");
_builder.append("X refs a1.a2 X.a1.a2 r.X.a1.a2 { a1 { a2 refs a2 { a3 { ref a3 } } } }");
_builder.newLine();
_builder.append("\t");
_builder.append("Y refs b1.b2 Y.b1.b2 r.Y.b1.b2 { b1 { b2 { ref b2 } } }");
_builder.newLine();
_builder.append("}");
_builder.newLine();
Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/file1.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:/file1.pstl", Node.class);
final IChangeSerializer serializer = this._changeSerializerTestHelper.newChangeSerializer();
final IChangeSerializer.IModification<Resource> _function = (Resource it) -> {
Node _head = IterableExtensions.<Node>head(IterableExtensions.<Node>head(IterableExtensions.<Node>head(model.getChildren()).getChildren()).getChildren());
_head.setName("b");
};
serializer.<Resource>addModification(model.eResource(), _function);
Assert.assertEquals(1, model.eResource().getResourceSet().getResources().size());
Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------");
_builder_1.newLine();
_builder_1.append("#1 r {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("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 } } } }");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("Y refs b1.b2 Y.b1.b2 r.Y.b1.b2 { b1 { b2 { ref b2 } } }");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("--------------------------------------------------------------------------------");
_builder_1.newLine();
_builder_1.append("15 5 \"a1.a2\" -> \"a1.b\"");
_builder_1.newLine();
_builder_1.append("21 7 \"X.a1.a2\" -> \"a1.b\"");
_builder_1.newLine();
_builder_1.append("29 9 \"r.X.a1.a2\" -> \"a1.b\"");
_builder_1.newLine();
_builder_1.append("46 2 \"a2\" -> \"b\"");
_builder_1.newLine();
_builder_1.append("54 2 \"a2\" -> \"b\"");
_builder_1.newLine();
this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_1);
}
Aggregations