Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Generating Enums with Xbase(I want to generate Enums with attributes)
Generating Enums with Xbase [message #1391264] Mon, 30 June 2014 17:14 Go to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
I want to generate Enums with attributes but I could not figure out how to put the constructor argument expressions to the JvmEnumerationLiterals definitions.

Is there a way to do this with the ModelInferrer or is there another way to do it?

Thanks
Re: Generating Enums with Xbase [message #1392107 is a reply to message #1391264] Tue, 01 July 2014 22:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
if you have a look at org.eclipse.xtext.xbase.compiler.JvmModelGenerator.generateEnumLiteral(JvmEnumerationLiteral, ITreeAppendable, GeneratorConfig)
you can see that it is not yet done.

so please file a bugzilla,

as a workaround you may subclass JvmModelGenerator.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Generating Enums with Xbase [message #1392510 is a reply to message #1392107] Wed, 02 July 2014 12:52 Go to previous messageGo to next message
Jan Rosczak is currently offline Jan RosczakFriend
Messages: 53
Registered: July 2009
Location: Hamburg, Germany
Member
I think there is already a bugzilla for this.

First subclass the JvmModelGenerator class and add something like this:
    override generateEnumLiteral(JvmEnumerationLiteral it, ITreeAppendable appendable, GeneratorConfig config) {
      super.generateEnumLiteral(it, appendable, config)
      compilationStrategy?.apply(appendable)
    }


And then you can do something like this in your inferrer:
element.toEnumerationLiteral("literal name, [		
    initializer = [
      append("(my attribute)")
    ]
]
Re: Generating Enums with Xbase [message #1392937 is a reply to message #1392107] Thu, 03 July 2014 02:48 Go to previous message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
Christian Dietrich wrote on Tue, 01 July 2014 18:25
if you have a look at org.eclipse.xtext.xbase.compiler.JvmModelGenerator.generateEnumLiteral(JvmEnumerationLiteral, ITreeAppendable, GeneratorConfig)
you can see that it is not yet done.

so please file a bugzilla,

as a workaround you may subclass JvmModelGenerator.

Thank you for the info.
Previous Topic:Adding a terminal makes UI editor fail?
Next Topic:How can I create a variable or static initializer with Xbase means
Goto Forum:
  


Current Time: Wed Apr 24 15:22:47 GMT 2024

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

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

Back to the top