use of org.eclipse.xtext.serializer.hiddentokensequencertest.Model in project xtext-core by eclipse.
the class SerializationAfterModelChangeTest method testAddElementAfterInlineComment.
@Test
public void testAddElementAfterInlineComment() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("entities");
_builder.newLine();
_builder.append("\t");
_builder.append("Foo \"Bar\"\t//inline comment before inserted element");
_builder.newLine();
_builder.append("end");
_builder.newLine();
final Model model = this._parseHelper.parse(_builder);
Entity _createEntity = HiddentokensequencertestFactory.eINSTANCE.createEntity();
final Procedure1<Entity> _function = (Entity it) -> {
it.setName("Baz");
it.setDescription("Fizzle");
};
final Entity event = ObjectExtensions.<Entity>operator_doubleArrow(_createEntity, _function);
model.getDomainModel().getEntities().add(event);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("entities");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("Foo \"Bar\"\t//inline comment before inserted element");
_builder_1.newLine();
_builder_1.append("Baz \"Fizzle\" end");
this.assertSerializesTo(model, _builder_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.serializer.hiddentokensequencertest.Model in project xtext-core by eclipse.
the class SerializationAfterModelChangeTest method testMoveElement.
/**
* TODO does not work yet, because HiddenTokenSequencer
* always searches in one direction,
* but the order of the elements has changed here.
*/
@Test
@Ignore
public void testMoveElement() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("entities");
_builder.newLine();
_builder.append("\t");
_builder.append("Foo \"Bar\"");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("//comment between elements");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("Baz \"Fizzle\"");
_builder.newLine();
_builder.append("end");
_builder.newLine();
final Model model = this._parseHelper.parse(_builder);
final Entity head = IterableExtensions.<Entity>head(model.getDomainModel().getEntities());
model.getDomainModel().getEntities().move(1, head);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("entities");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("Baz \"Fizzle\"");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("//comment between elements");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("Foo \"Bar\"");
_builder_1.newLine();
_builder_1.append("end");
_builder_1.newLine();
this.assertSerializesTo(model, _builder_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.serializer.hiddentokensequencertest.Model in project xtext-core by eclipse.
the class SerializationAfterModelChangeTest method testUnrelatedCommentBeforeRemovedElement.
@Test
public void testUnrelatedCommentBeforeRemovedElement() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("entities");
_builder.newLine();
_builder.append("\t");
_builder.append("Foo \"Bar\"");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("//unrelated comment before deleted element");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("Baz \"Fizzle\"");
_builder.newLine();
_builder.append("end");
_builder.newLine();
final Model model = this._parseHelper.parse(_builder);
model.getDomainModel().getEntities().remove(1);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("entities");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("Foo \"Bar\"");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("//unrelated comment before deleted element");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("end");
this.assertSerializesTo(model, _builder_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.serializer.hiddentokensequencertest.Model in project xtext-core by eclipse.
the class SerializationAfterModelChangeTest method testRemoveElementInSameLine.
@Test
public void testRemoveElementInSameLine() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("entities");
_builder.newLine();
_builder.append("\t");
_builder.append("Foo \"Bar\" /* the foo */ Baz \"Fizzle\"");
_builder.newLine();
_builder.append("end");
_builder.newLine();
final Model model = this._parseHelper.parse(_builder);
model.getDomainModel().getEntities().remove(1);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("entities");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("Foo \"Bar\" /* the foo */");
_builder_1.newLine();
_builder_1.append("end");
this.assertSerializesTo(model, _builder_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.serializer.hiddentokensequencertest.Model in project xtext-core by eclipse.
the class SerializationAfterModelChangeTest method smokeTest.
@Test
public void smokeTest() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("entities");
_builder.newLine();
_builder.append("\t");
_builder.append("//before existing element");
_builder.newLine();
_builder.append("\t");
_builder.append("Foo /* within existing element */ \"Bar\" /* after existing element*/");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("//unrelated comment");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("//before deleted element");
_builder.newLine();
_builder.append("\t");
_builder.append("Baz \"Fizzle\" /* after deleted element */");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("//between deleted elements");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("//another deleted element");
_builder.newLine();
_builder.append("\t");
_builder.append("Blurb /* a comment within a deleted element */ \"Bla\"");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("//before inserted element");
_builder.newLine();
_builder.append("end");
_builder.newLine();
final Model model = this._parseHelper.parse(_builder);
Entity _createEntity = HiddentokensequencertestFactory.eINSTANCE.createEntity();
final Procedure1<Entity> _function = (Entity it) -> {
it.setName("AAA");
it.setDescription("BBB");
};
final Entity event = ObjectExtensions.<Entity>operator_doubleArrow(_createEntity, _function);
model.getDomainModel().getEntities().remove(1);
model.getDomainModel().getEntities().remove(1);
model.getDomainModel().getEntities().add(event);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("entities");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("//before existing element");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("Foo /* within existing element */ \"Bar\" /* after existing element*/");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("//unrelated comment");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("//between deleted elements");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("//before inserted element");
_builder_1.newLine();
_builder_1.append("AAA \"BBB\" end");
this.assertSerializesTo(model, _builder_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations