|[Xtext] Using existing enums from imported metamodel [message #517508]
||Sun, 28 February 2010 22:46
Originally posted by: ogucuk.gmail.com|
Dear Xtext gurus,
is it not possible to directly use the enumerations that are defined in
an imported metamodel without explicitely introducing them in the grammar?
We use an imported metamodel instead of generating our own from the
Xtext grammar. In our Ecore metamodel, we had already defined literals
for our enumerations. Now we want to reference the enumeration in our
Xtext grammar, i.e:
Code generations is no problem but in the editor I do not see the enum
literals in content assist. Also if I type the predefined literals, I
get parser errors.
What am I missing?
|Re: [Xtext] Using existing enums from imported metamodel [message #517527 is a reply to message #517524]
||Mon, 01 March 2010 08:25
| Sebastian Zarnekow
Registered: July 2009
it is not possible to use enums without declaring an enum rule.
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 01.03.10 08:56, schrieb Özgün:
> Hi Sebastian,
> thanks again, for your prompt responses.
> If I leave the brackets and the metamodel alias, Xtext thinks EnumType
> is a parser rule and cannot resolve it. I was kind of hoping, maybe in
> that case the brackets do mean that it is imported :) and not a
> cross-ref. Do you have any suggestions?
> Well, it is not a big deal but we would be happy if we could release the
> grammar from the double declaration of enumerations (once in metamodel
> and once in the grammar).
> Thanking you
> Sebastian Zarnekow schrieb:
>> Hi Özgün,
>> since enumerations are datatypes, I doubt that you can use them in a
>> cross reference.
>> You could use you EnumType as follows:
>> enum EnumType returns metamodel::EnumType:
>> Foo | Bar;
>> You have to list the enum literals because the grammar describes the
>> abstract and the concrete syntax. E.g. there may be situations where
>> you do not want to use every defined literal in your concrete syntax.
>> Hope that helps,
Powered by FUDForum
. Page generated in 0.01612 seconds