Old vs new serializer [message #1116499] |
Wed, 25 September 2013 10:26  |
Eclipse User |
|
|
|
Hi,
I'm currently using the old serializer to save a dsl model after having applied some transformations over it. It's working except that:
* the newly serialized model elements are present in the model in a different order
* some elements are printed on the same line as their predecessors (couldn't see what was different in my grammar)
I'm wondering if the new serializer could solve my problems or if I had to manage that differently.
If yes, I'm wondering how can I use the new serializer. For the old one, I extended the org.eclipse.xtext.parsetree.reconstr.Serializer, retrieve it by the IGlobalServiceProvider and call the serialize() method that gave me back the serialized string that I passed to an EclipseResourceFileSystemAccess2. How can I actually use the new one (couldn't find the info in the documentation).
Thanks in advance,
Cheers,
Fabian
|
|
|
|
|
|
|
|
Re: Old vs new serializer [message #1117350 is a reply to message #1117294] |
Thu, 26 September 2013 06:47   |
Eclipse User |
|
|
|
Hi Moritz,
I did not touch to the formatter. It seems the serializer follows the order defined in the grammar and if two dsl elements are interchanged, the serialization produces a strange behaviour. An example grammar (did not test with this example, but have the same pattern in my language with a bigger abstract rule) :
ASampleRule :
(sub1+=SubRule1 | sub2+=SubRule2)*;
SubRule1 :
'subrule1' name=ID ';';
SubRule2 :
'subrule2' name=ID ';';
The model:
subrule1 id1;
// a comment
subrule2 id2;
will be serialized correctly, but the model:
// a comment
subrule2 id2;
// a comment
subrule1 id1;
will produce
subrule2 id2; subrule1 id1;
In other words, when a couple of rules can be present in multiple instances and interchanged, it seems the serializer does not produce the expected result. For the order, this is no big deal, but the comments defined upper and in between are lost which is more problematic.
Thanks for your help,
Regards,
Fabian
[Updated on: Thu, 26 September 2013 06:58] by Moderator
|
|
|
|
|
|
|
Re: Old vs new serializer [message #1117512 is a reply to message #1117464] |
Thu, 26 September 2013 10:25  |
Eclipse User |
|
|
|
Tested after reformating the rules, serializer behaves as expected.
Moreover, as a side effect, I could remove a quick-dirty-fix for the scope provider that was not working correctly for one type of reference.
So, if you have the same problem, one advice, reformat the rule as suggested by Uli.
|
|
|
Powered by
FUDForum. Page generated in 0.08447 seconds