use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.Node 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.tests.testlanguage.partialSerializationTestLanguage.Node 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);
}
use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.Node in project xtext-core by eclipse.
the class PartialSerializerTest method testMoveInList1.
@Test
public void testMoveInList1() {
final IChangeSerializer.IModification<Node> _function = (Node it) -> {
it.getChildren().move(0, 1);
};
ITextRegionAccess _recordDiff = this.<Node>recordDiff(Node.class, "#1 root { Foo; Bar; }", _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("0 0 H");
_builder.newLine();
_builder.append(" ");
_builder.append("B Node\'root\' Model");
_builder.newLine();
_builder.append(" ");
_builder.append("0 2 S \"#1\" Model:\'#1\'");
_builder.newLine();
_builder.append(" ");
_builder.append("2 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append(" ");
_builder.append("3 4 S \"root\" Node:name=ID");
_builder.newLine();
_builder.append(" ");
_builder.append("7 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append(" ");
_builder.append("8 1 S \"{\" Node:\'{\'");
_builder.newLine();
_builder.append(" ");
_builder.append("9 1 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append(" ");
_builder.append("B Node\'Bar\' Node:children+=Node path:Node\'root\'/children[0]");
_builder.newLine();
_builder.append("10 3 1 S \"Bar\" Node:name=ID");
_builder.newLine();
_builder.append("13 0 1 H");
_builder.newLine();
_builder.append("13 1 1 S \";\" Node:\';\'");
_builder.newLine();
_builder.append(" ");
_builder.append("E Node\'Bar\' Node:children+=Node path:Node\'root\'/children[0]");
_builder.newLine();
_builder.append("14 0 1 H");
_builder.newLine();
_builder.append(" ");
_builder.append("B Node\'Foo\' Node:children+=Node path:Node\'root\'/children[1]");
_builder.newLine();
_builder.append("14 3 S \"Foo\" Node:name=ID");
_builder.newLine();
_builder.append("17 0 H");
_builder.newLine();
_builder.append("17 1 S \";\" Node:\';\'");
_builder.newLine();
_builder.append(" ");
_builder.append("E Node\'Foo\' Node:children+=Node path:Node\'root\'/children[1]");
_builder.newLine();
_builder.append("18 2 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append(" ");
_builder.append("2 \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append("20 1 S \"}\" Node:\'}\'");
_builder.newLine();
_builder.append(" ");
_builder.append("E Node\'root\' Model");
_builder.newLine();
_builder.append("21 0 H");
_builder.newLine();
_builder.append("------------ diff 1 ------------");
_builder.newLine();
_builder.append(" ");
_builder.append("9 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append("10 3 S \"Foo\" Node:name=ID");
_builder.newLine();
_builder.append("------------ diff 2 ------------");
_builder.newLine();
_builder.append("14 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append("15 3 S \"Bar\" Node:name=ID");
_builder.newLine();
_builder.append("18 0 H");
_builder.newLine();
_builder.append("18 1 S \";\" Node:\';\'");
_builder.newLine();
_builder.append("19 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.Node in project xtext-core by eclipse.
the class PartialSerializationTestLanguageFormatter method _format.
protected void _format(final Node obj, @Extension final IFormattableDocument document) {
List<ISemanticRegion> _keywords = this.textRegionExtensions.regionFor(obj).keywords(";");
for (final ISemanticRegion r : _keywords) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.append(document.prepend(r, _function), _function_1);
}
EList<Node> _children = obj.getChildren();
for (final Node child : _children) {
document.<Node>format(child);
}
}
use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.Node in project xtext-core by eclipse.
the class NodeImpl method setRef.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setRef(Node newRef) {
Node oldRef = ref;
ref = newRef;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, PartialSerializationTestLanguagePackage.NODE__REF, oldRef, ref));
}
Aggregations