|Re: Inserting Comments at the Top of an XText Resource at Serialization Time [message #1051199 is a reply to message #1047610]
||Sun, 28 April 2013 11:22
| Jan Koehnlein
Registered: July 2009
A comment does not have a representation in the semantic model, |
therefore it cannot be added to the semantic model.
Usually Xtext stores the textual representation in a parallel model (the
node model), but this one does not exist if you create the resource as a
semantic EMF model only. The node model is only created by the parser
which you don't use in your scenario at all.
1) Implement a post processor, inserting the comments into the saved
models (reopen as text files, add comment, save)
2) Instead of calling Resource.save(Map<?,?>) call
Resource.save(OutputStream, Map<?,?>) and write the comment into the
output stream before.
3) Serialize the semantic model, parse the resulting string again and
then add the comment textually, e.g. using XtextResource.update(0,0, "//
3) Write and bind your own XtextResource or ISerializer and hook into
the doSave or serialize methods.
Am 23.04.13 14:47, schrieb Ronan B:
> I'm generating an XText resource as an output of an ATL transformation.
> I want to be able to put in a comment at the top of the output file to
> give the user some details about the version of the transformer used to
> generate the output file.
> I'm finding it very hard to figure out how to do this in Xtext. The
> forum/manual talk about comments but it is normally about preservation
> rather than insertion. Any advise is appreciated. Usualy, when not using
> Xtext, I just edit the Ecore GenModel class that extends EFactoryImpl
> and add comments in at the right spot as Ecore can serialize them for me
> e.g. In the createDocumentRoot() method if using an XML based serializer.
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Powered by FUDForum
. Page generated in 0.01709 seconds