Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Code Generation in RunTime(doGenerate method)
icon12.gif  Code Generation in RunTime [message #1721235] Tue, 26 January 2016 04:57 Go to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Hi ,

I am exploring code generation with web -editor. I would like to generate code(another file) on runtime (when I type in the UI editor). I have also changed the generate method based on my requirement . I am trying to debug. I see that this method is not even executed. Am I missing something.Can I trigger code generation in runtime.?


Please suggest.

override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {

fsa.generateFile("relative/path/AllTheStates.txt", '''
«FOR measure : resource.allContents.filter(Measure).toIterable»
Qr «measure»
«ENDFOR»
''')
Re: Code Generation in RunTime [message #1721238 is a reply to message #1721235] Tue, 26 January 2016 05:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Are you sure you call the generator service?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Code Generation in RunTime [message #1721239 is a reply to message #1721238] Tue, 26 January 2016 06:04 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
No I am not calling explicitly . Should I call in javascript or add a configuration that generator has to be called.?
Re: Code Generation in RunTime [message #1721241 is a reply to message #1721239] Tue, 26 January 2016 06:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Did you a look at the example I gave you? With the generate button?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Code Generation in RunTime [message #1721242 is a reply to message #1721241] Tue, 26 January 2016 06:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
It actually was not you https://www.eclipse.org/forums/index.php/t/1073968/

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Code Generation in RunTime [message #1721243 is a reply to message #1721242] Tue, 26 January 2016 06:31 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Ok. I tried it . I get
"Problem accessing /xtext-service/generate. Reason:

Unable to identify the Xtext language"

Please suggest
Re: Code Generation in RunTime [message #1721244 is a reply to message #1721243] Tue, 26 January 2016 06:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
make sure you get the file extension right

<div id="xtext-editor" data-editor-xtext-lang="mydsl2" data-editor-resource-id="example1.mydsl2"></div>

jQuery('#generator-result').html('<iframe src="http://' + location.host + '/xtext-service/generate?resource=example1.mydsl2"></iframe>');


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
icon14.gif  Re: Code Generation in RunTime [message #1721259 is a reply to message #1721244] Tue, 26 January 2016 08:31 Go to previous message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Thanks.
Previous Topic:[Xtext2.7.3 to 2.9.1]Eclipse application is broken with xcore
Next Topic:Problems with code generator
Goto Forum:
  


Current Time: Fri Mar 29 09:42:34 GMT 2024

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

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

Back to the top