Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » JVMModelInferrer code generation(JVMModelInferrer code generation)
JVMModelInferrer code generation [message #1815479] Thu, 03 October 2019 09:55 Go to next message
Vikas Verma is currently offline Vikas VermaFriend
Messages: 3
Registered: October 2019
Junior Member
Iam using Xtext in my project to generated java classes from the DSL.
Created custom inferrer by extending AbstractModelInferrer.
I have a requirement where i need to generate code using a set of xtext resources. i want to generate a single common class class for all the resource and generate fields in the class for individual resources.

Problem is that infer method is invoked for a single resource so i cannot generate a class that is common across all the resources.

Is there any way that i can infer the resourceSet instead of a single resource
Re: JVMModelInferrer code generation [message #1815504 is a reply to message #1815479] Thu, 03 October 2019 15:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
I don't know any possibility to do this with jvm model inferrer.
In General this is possible though (I don't know if you want to call into that multi class, if not you could use it)

Here is a very old blog post https://www.google.de/amp/s/kthoms.wordpress.com/2011/07/12/xtend-generating-from-multiple-input-models/amp/


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: JVMModelInferrer code generation [message #1815553 is a reply to message #1815479] Fri, 04 October 2019 17:59 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Old but gold ;-) Might not 100% up-to-date, but the principle is still the same.
Re: JVMModelInferrer code generation [message #1816073 is a reply to message #1815553] Fri, 18 October 2019 20:26 Go to previous messageGo to next message
Vikas Verma is currently offline Vikas VermaFriend
Messages: 3
Registered: October 2019
Junior Member
Thanks Christian, code generation is possible with the way in your post but the problem is that the single common class generated from all the resources is not accessible in the other generated classes.
Xtext validation fails. It complains for the missing type for the generated class type. I am trying to access the class in the xblockxpresssion .

Code generation will not work if in the generated code we are trying to access the generated common class from all the resources.
Re: JVMModelInferrer code generation [message #1816075 is a reply to message #1816073] Fri, 18 October 2019 21:31 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
As said before!.

(I don't know if you want to call into that multi class, if not you could use it)

The inferrer does not support this usecase


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 18 October 2019 21:32]

Report message to a moderator

Previous Topic:generateTracedFile is undefined for the type IFileSystemAccess2
Next Topic:Add Xtext content to toolbar
Goto Forum:
  


Current Time: Fri Apr 26 12:46:41 GMT 2024

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

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

Back to the top