Some comments disappear when model is manipulated [message #1220761] |
Fri, 13 December 2013 13:08 |
Espinosa CZ Messages: 27 Registered: July 2009 |
Junior Member |
|
|
Hi guys,
I am doing something wrong in my model manipulation/serialization code, or xtext model definition in regards of comment? Or did I stumbled upon a Xtext bug?
Basically comments disappears from my DSL at/around point of model modification, like adding or missing elements or removing wrong element.
Both // (double slash line comment) and /* */ (block comments) both courtesy of included Xbase grammar (right?).
I found this issue when I was testing my Quick Fix provider, I then extracted this unit test to demonstrate the issue:
/** FAILS */
@Test
def void addFieldToModelAndSerializeBack_testCommentsHandling_simplestCase() {
val sample = '''
deepClone
package my.home.cloners
a.b.m.Magazine {
// comment 1
}
'''
val expectedModifiedSample = '''
deepClone
package my.home.cloners
a.b.m.Magazine {
// comment 1
fooFoo
}
'''.toString
val model = parser.parse(sample)
val articleContainerField = (model as Body).cloners.get(0).asContainer
articleContainerField.addFields(newArrayList("fooFoo")) // do tested model manipulation
val result = model.serialize
assertEquals(
expectedModifiedSample,
result
)
}
instead of expected:
deepClone
package my.home.cloners
a.b.m.Magazine {
// comment 1
fooFoo
}
I get:
deepClone
package my.home.cloners
a.b.m.Magazine {
fooFoo
}
The comment completely disappears.
Same happens when I remove some elements from a Cloner; from root element or deeper in more complex structures.
Please check my complete unit test for further details, wat works and what does not:
https://bitbucket.org/espinosa/deepclone/src/218c858feb6c0d02a332dde598138089e57f765a/my.home.dsl.DeepClone.tests/src/my/home/dsl/deepclone/Test6DeepCloneModelManipulation.xtend?at=master
I did some further test, see my DeepCloneModelManipulationTest, and found that all comments following the spot where change in the model was made disappear when model is serialized.
I am still using Xtext 2.4.3; I have just spot you released a new version of Xtext and Xtend. 2.5.0. Great! I will give it a go and if the issue is still present I will submit a bug report.
[Updated on: Fri, 13 December 2013 13:09] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08419 seconds