Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Is a reference to an Enumeration Literal possible?
Is a reference to an Enumeration Literal possible? [message #1436905] Fri, 03 October 2014 15:38 Go to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 148
Registered: February 2013
Senior Member
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:

property group MY_GROUP


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 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
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
Re: Is a reference to an Enumeration Literal possible? [message #1438516 is a reply to message #1437075] Mon, 06 October 2014 06:16 Go to previous message
Markus Duft is currently offline Markus DuftFriend
Messages: 148
Registered: February 2013
Senior Member
Hey,

Thanks a lot. I had nearly everything but missed that i had an unresolved proxy somewhere in my scope provider, which caused a collection to be empty... After resolving that proxy manually everything works like a charm! Your answer showed me I'm on the right track Very Happy

Cheers,
Markus
Previous Topic:XtextDay - EclipseCon 2015 San Francisco - CFP
Next Topic:Open .xtext grammar in ModelEditor
Goto Forum:
  


Current Time: Fri Apr 26 03:29:52 GMT 2024

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

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

Back to the top