Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Is there a better way to handle this?
Is there a better way to handle this? [message #1006841] Sat, 02 February 2013 18:46 Go to next message
Luigi is currently offline LuigiFriend
Messages: 10
Registered: November 2009
Location: Italy
Junior Member
Hi,

I have the following construction in my xtext grammar:

StructType:
'struct' name=ID '{'
(structMembers+=StructMember)*
'}'
;

StructMember:
{StructMemberSub} isString?='string' name=ID ';' |
{StructMemberSub} isInt?='int' name=ID ';'
;

StructMemberSub:
needsProcessing?='Never Use This From The Source'
;

The rule StructMemberSub is introduced to:
- get the flag needsProcessing in the ecore model
- disallow the generated implementation to set the flag or generate the
proposal for it through content assist.

I want the flag needsProcessing in the ecore model so that in the
generator, I can calculate it's value in the first pass and act on it in
a later pass.

It works, but is seems to me there should be a better way to achieve
adding an attribute to a class in the ecore model from the xtext grammar
file.

Looking forward any suggestions.

Regards,

Luigi
Re: Is there a better way to handle this? [message #1006842 is a reply to message #1006841] Sat, 02 February 2013 18:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14718
Registered: July 2009
Senior Member
Hi,

you have basically 3 options

(1) your way
(2) a manually maintained metamodel
(3) postprocess the metamodel (e.g. http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Is there a better way to handle this? [message #1006957 is a reply to message #1006842] Sun, 03 February 2013 07:35 Go to previous messageGo to next message
Luigi is currently offline LuigiFriend
Messages: 10
Registered: November 2009
Location: Italy
Junior Member
On 2-2-2013 19:53, Christian Dietrich wrote:
> Hi,
>
> you have basically 3 options
>
> (1) your way
> (2) a manually maintained metamodel
> (3) postprocess the metamodel (e.g.
> http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/)
>

Hi Christian,

thanks for your reply. I liked your third option the most. Through your
blog and some others searches, mainly
http://malubu.wordpress.com/2012/05/07/post-processing-vs-post-initialization/,
I ended up creating a <languageName>PostProcessor.ext file.

Thanks for the pointer!

Regards,

Luigi
Re: Is there a better way to handle this? [message #1006980 is a reply to message #1006842] Sun, 03 February 2013 14:01 Go to previous messageGo to next message
Luigi is currently offline LuigiFriend
Messages: 10
Registered: November 2009
Location: Italy
Junior Member
On 2-2-2013 19:53, Christian Dietrich wrote:
> Hi,
>
> you have basically 3 options
>
> (1) your way
> (2) a manually maintained metamodel
> (3) postprocess the metamodel (e.g.
> http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/)
>

Hi,

I have been succesful with adding types like EBoolean and EString to the
metamodel using the postprocessing step. But I am less successful when I
want to add a reference to a type defined in the grammar.

I would be helped with an example of how to add a reference to an EClass
where the reference type is defined in the grammar.

Kind regards,

Luigi
Re: Is there a better way to handle this? [message #1006981 is a reply to message #1006980] Sun, 03 February 2013 14:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14718
Registered: July 2009
Senior Member
Hi don't get your point. Create a new reference and set the etype.
Therefore traverse the model and search your type

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Is there a better way to handle this? [message #1007175 is a reply to message #1006981] Mon, 04 February 2013 18:22 Go to previous message
Luigi is currently offline LuigiFriend
Messages: 10
Registered: November 2009
Location: Italy
Junior Member
On 3-2-2013 15:18, Christian Dietrich wrote:
> Hi don't get your point. Create a new reference and set the etype.
> Therefore traverse the model and search your type
>

Yes, it's that simple. I just didn't realize that the model was passed
in as a argument to the post process function.
Previous Topic:Infinite loop when refreshing the outline
Next Topic:Firing command after perspective is changed
Goto Forum:
  


Current Time: Thu Sep 26 20:09:34 GMT 2024

Powered by FUDForum. Page generated in 0.05069 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top