Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xtend] Using EEnum Literals within Xtend expressions
[Xtend] Using EEnum Literals within Xtend expressions [message #545947] Fri, 09 July 2010 16:40 Go to next message
Abdull is currently offline AbdullFriend
Messages: 32
Registered: May 2010
Member
So in my Ecore metamodel (Name / Ns Prefix "hl_dsp_pimm_02") I have an EEnum called "DataType".
It has "EEnum Literals" such as "Float", "Sint16", etc.

I require access to these enum literals within my Xtend model transformation.
That is I have an expression such as
let someDataType = hl_dsp_pimm_02::DataType::SINT16 :


When I try to run my workflow, I get the following exception ...
EvaluationException : Couldn't find enum literal or type 'hl_dsp_pimm_02::DataType::SINT16'

... even though I have imported hl_dsp_pimm_02 in my Xtend file, and even though I can work with any other meta model elements such as my hl_dsp_pimm_02's EClasses, EReferences etc.

Any ideas on how to access EEnum literals?
Thank you all once again!
Re: [Xtend] Using EEnum Literals within Xtend expressions [message #546036 is a reply to message #545947] Sat, 10 July 2010 07:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello,

which version of xpand/xtend do you use? i tried it with 1.0.0
and something like

<<this.attr == mypackage::MyEnum::MyEnumLiteralName>>

works. But note MyEnumLiteralName is the Name attribute of the eenumliteral and not the Literal attribute

Regards
Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtend] Using EEnum Literals within Xtend expressions [message #546059 is a reply to message #546036] Sat, 10 July 2010 15:13 Go to previous message
Abdull is currently offline AbdullFriend
Messages: 32
Registered: May 2010
Member
Hello Christian,

thank you very much, it seems that your hint solved my problem!

The problem was I used
hl_dsp_pimm_02::DataType::SINT16
where I should have used
hl_dsp_pimm_02::DataType::Sint16


... That is, you mustn't use the spelling as hinted in the enum type of the auto-generated Java file (SINT16), but you have to use the same case-sensitive writing of the EEnum Literal as written in its "name" property (Sint16).
Previous Topic:Referencing ecore primitive types in Xtend
Next Topic:[Xtend] Problem with JAVA Extension -> static initializer -> EFactory
Goto Forum:
  


Current Time: Tue Apr 23 07:48:26 GMT 2024

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

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

Back to the top