Skip to main content



      Home
Home » Modeling » TMF (Xtext) » JVMModelInferrer code generation(JVMModelInferrer code generation)
JVMModelInferrer code generation [message #1815479] Thu, 03 October 2019 05:55 Go to next message
Eclipse UserFriend
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 11:43 Go to previous messageGo to next message
Eclipse UserFriend
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/
Re: JVMModelInferrer code generation [message #1815553 is a reply to message #1815479] Fri, 04 October 2019 13:59 Go to previous messageGo to next message
Eclipse UserFriend
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 16:26 Go to previous messageGo to next message
Eclipse UserFriend
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 17:31 Go to previous message
Eclipse UserFriend
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

[Updated on: Fri, 18 October 2019 17:32] by Moderator

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


Current Time: Mon Mar 17 14:41:45 EDT 2025

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

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

Back to the top