@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); DomainModel _domainModel = model.getDomainModel(); EList<Entity> _entities = _domainModel.getEntities(); _entities.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); } }
@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); DomainModel _domainModel = model.getDomainModel(); EList<Entity> _entities = _domainModel.getEntities(); _entities.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); } }
/** * 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); DomainModel _domainModel = model.getDomainModel(); EList<Entity> _entities = _domainModel.getEntities(); final Entity head = IterableExtensions.<Entity>head(_entities); DomainModel _domainModel_1 = model.getDomainModel(); EList<Entity> _entities_1 = _domainModel_1.getEntities(); _entities_1.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); } }
@Test public void testCommentOnRemovedElement() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("entities"); _builder.newLine(); _builder.append("\t"); _builder.append("Foo \"Bar\" //inline comment before deleted element"); _builder.newLine(); _builder.append("\t"); _builder.append("//comment on deleted element"); _builder.newLine(); _builder.append("\t"); _builder.append("/**"); _builder.newLine(); _builder.append("\t "); _builder.append("* another comment on the deleted element"); _builder.newLine(); _builder.append("\t "); _builder.append("*/"); _builder.newLine(); _builder.append("\t"); _builder.append("Baz \"Fizzle\""); _builder.newLine(); _builder.append("end"); _builder.newLine(); final Model model = this._parseHelper.parse(_builder); DomainModel _domainModel = model.getDomainModel(); EList<Entity> _entities = _domainModel.getEntities(); _entities.remove(1); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("entities"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("Foo \"Bar\" //inline comment before deleted element"); _builder_1.newLine(); _builder_1.newLine(); _builder_1.append("end"); this.assertSerializesTo(model, _builder_1); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@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); DomainModel _domainModel = model.getDomainModel(); EList<Entity> _entities = _domainModel.getEntities(); _entities.remove(1); DomainModel _domainModel_1 = model.getDomainModel(); EList<Entity> _entities_1 = _domainModel_1.getEntities(); _entities_1.remove(1); DomainModel _domainModel_2 = model.getDomainModel(); EList<Entity> _entities_2 = _domainModel_2.getEntities(); _entities_2.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); } }