Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Code Generator in java(Not able to invoke the java code generator)
Code Generator in java [message #1111656] Wed, 18 September 2013 10:40 Go to next message
Sheetal Bhatewara is currently offline Sheetal Bhatewara
Messages: 13
Registered: August 2013
Junior Member
I have a grammar written in .xtext file.
Now, the default code generator is in .xtend.
But writing code generator in xtend is not easy for me, as syntax of xtend is new for me.
So, I want to change it to .java code generator.

So, if anyone has worked on it, then please let me know the steps to invoke the java code generator.

[ Right now, with .xtend, using my grammer , the files are getting generated at default location src-gen]

Re: Code Generator in java [message #1111729 is a reply to message #1111656] Wed, 18 September 2013 12:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6126
Registered: July 2009
Senior Member
Hi,

if you really want to give you the pain...

(1) delete the Generator.xtend
(2) change the workflow to
    		fragment = generator.GeneratorFragment auto-inject {
    			generateStub = false
    		}

(3) rerun the workflow
(4) create the missing Class in Java
Re: Code Generator in java [message #1112155 is a reply to message #1111729] Thu, 19 September 2013 03:35 Go to previous messageGo to next message
Sheetal Bhatewara is currently offline Sheetal Bhatewara
Messages: 13
Registered: August 2013
Junior Member
Thanks Christian for your quick response.

One query in the approach suggested by you.
Is it mandatory to implement IGenerator in the newly created class?( As the default .xtend had it)
Because, it seems, if we don't then generator invocation is not happening.
Re: Code Generator in java [message #1112174 is a reply to message #1111729] Thu, 19 September 2013 04:05 Go to previous messageGo to next message
Sheetal Bhatewara is currently offline Sheetal Bhatewara
Messages: 13
Registered: August 2013
Junior Member
While changing workflow, is it 'generateStub = false' or 'generatorStub = false'?
generateStub = false is giving compilation error , and suggesting it to change to
'generatorStub = false'
Re: Code Generator in java [message #1112177 is a reply to message #1112155] Thu, 19 September 2013 04:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6126
Registered: July 2009
Senior Member
Yes it is

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Code Generator in java [message #1112182 is a reply to message #1112174] Thu, 19 September 2013 04:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6126
Registered: July 2009
Senior Member
Change it to what auto completion suggests. I tested with 2.4.3

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Code Generator in java [message #1112901 is a reply to message #1111656] Fri, 20 September 2013 06:37 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten Thoms
Messages: 353
Registered: July 2009
Location: Dortmund
Senior Member

No Message Body

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Code Generator in java [message #1112903 is a reply to message #1112901] Fri, 20 September 2013 06:39 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten Thoms
Messages: 353
Registered: July 2009
Location: Dortmund
Senior Member

You should really take some hours (its not more than that) to learn Xtend. It is highly NOT RECOMMENDED to write code generators in Java. Xtend is well suited for this use case, and it is really close to the Java language.

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Code Generator in java [message #1123375 is a reply to message #1112903] Wed, 02 October 2013 09:53 Go to previous message
Sheetal Bhatewara is currently offline Sheetal Bhatewara
Messages: 13
Registered: August 2013
Junior Member
Done using java, thanks all for help!
Previous Topic:Case-insensitive check for unique names
Next Topic:Xbase + Inferrer in Eclipse Editor
Goto Forum:
  


Current Time: Thu Jul 24 02:36:39 EDT 2014

Powered by FUDForum. Page generated in 0.02828 seconds