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 14:40 Go to next message
Sheetal Bhatewara is currently offline Sheetal BhatewaraFriend
Messages: 14
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 16:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6540
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 07:35 Go to previous messageGo to next message
Sheetal Bhatewara is currently offline Sheetal BhatewaraFriend
Messages: 14
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 08:05 Go to previous messageGo to next message
Sheetal Bhatewara is currently offline Sheetal BhatewaraFriend
Messages: 14
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 08:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6540
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 08:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6540
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 10:37 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 360
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 10:39 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 360
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 13:53 Go to previous message
Sheetal Bhatewara is currently offline Sheetal BhatewaraFriend
Messages: 14
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 Dec 18 10:40:26 GMT 2014

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

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