Is a reference to an Enumeration Literal possible? [message #1436905] |
Fri, 03 October 2014 15:38 |
|
Hey,
I'm trying to do something like this:
GroupProperty:
// Allowed are only literals of a certain enumeration
'property' 'group' group=[jvmTypes::JvmEnumerationLiteral|FQName] ';'
;
ultimately I'd like to write something like:
where MY_GROUP is a literal of a special (existing) java enumeration
public enum ProcessGroup {
MY_GROUP, ...
}
Is this doable at all? If yes, could you give me a hint on how to proceed? Somehow every possible (fully-qualified for the first try) of writing the reference does not work (i.e. i tried this but it wouldn't resolve):
property group com.wamas.test.ProcessGroup.MY_GROUP;
Edit: More or less the only purpose is to not duplicate the existing enum in the xtext grammar, so that i can change it in one place afterwards, and without having to touch the xtext plugins.
Thanks in advance!
[Updated on: Fri, 03 October 2014 15:42] Report message to a moderator
|
|
|
Re: Is a reference to an Enumeration Literal possible? [message #1437075 is a reply to message #1436905] |
Fri, 03 October 2014 21:30 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Am 03.10.14 17:38, schrieb Markus Duft:
> Is this doable at all? If yes, could you give me a hint on how to
> proceed?
Hi Markus,
yes, that's possible though you have to customize the scoping of your
language. If the enum is well defined and statically known when you
write the grammar, it doesn't even need to be a FQName. You could
direclty provide the literals from the known enum.
If you want some kind of flexibility, you'd have to split it into two
cross references and customize the scoping, too.
GroupProperty:
// Allowed are only literals of a certain enumeration
'property' 'group' enum=[jvmTypes::JvmEnumerationTyüpe|FQName] '.'
group=[JvmEnumerationLiteral]';'
;
I'd recommend the first possibily and customize the scope provider. The
docs should give you a starting point.
Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
|
|
|
|
Powered by
FUDForum. Page generated in 0.03451 seconds