[Xtext] implement toString() with the ParseTreeConstructor [message #659244] |
Fri, 11 March 2011 15:54 |
|
Hi,
I'm wondering if there is a way ((static) utility method or something
like this) for creating a String from a model object according to the
grammar. That is, I want to print out my model elements according to the
grammer, mainly for debugging purposes. In some cases, I do not have an
Xtext text file but only the model elements.
I figure it should be possible to use the generated parse tree
constructor to achieve that, isn't it? (I do not need the formatter).
Before I start digging into the constructor, I was wondering if some
kind of utility class doing exactly this already exists?
Actually, what I want to do is to replace the generated toString()
methods in my model implementation with this grammar like output. Maybe
there is a hidden switch to even enable that? Or do I have to do this
myself, e.g. by implementing a post processor transformation adding the
toString body to the model elements?
Cheers,
Jens
|
|
|
Re: [Xtext] implement toString() with the ParseTreeConstructor [message #659266 is a reply to message #659244] |
Fri, 11 March 2011 17:48 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
Did you look at Serialization? - it produces text/string from the model.
- henrik
On 3/11/11 4:54 PM, Jens v.P. wrote:
> Hi,
>
> I'm wondering if there is a way ((static) utility method or something
> like this) for creating a String from a model object according to the
> grammar. That is, I want to print out my model elements according to the
> grammer, mainly for debugging purposes. In some cases, I do not have an
> Xtext text file but only the model elements.
>
> I figure it should be possible to use the generated parse tree
> constructor to achieve that, isn't it? (I do not need the formatter).
> Before I start digging into the constructor, I was wondering if some
> kind of utility class doing exactly this already exists?
>
> Actually, what I want to do is to replace the generated toString()
> methods in my model implementation with this grammar like output. Maybe
> there is a hidden switch to even enable that? Or do I have to do this
> myself, e.g. by implementing a post processor transformation adding the
> toString body to the model elements?
>
> Cheers,
>
> Jens
|
|
|
|
Powered by
FUDForum. Page generated in 0.02281 seconds