Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Multiple Generator calls on Xtext language(Multiple Generator calls on Xtext language)
Multiple Generator calls on Xtext language [message #1841475] Tue, 18 May 2021 11:35 Go to next message
Thomas Landuyt is currently offline Thomas LanduytFriend
Messages: 1
Registered: May 2021
Junior Member

We are having a project where we are using Xtext to generate a grammar and create from this language a java output file. Next to that we want to create also a kind of json output file. which has another extension. For this we want to split the generators to not mix the java generation and the json generation. Is there anyway we can call 2 Igenerators when compiling dsl grammar?

Example: We have 1 language common which generates java file for this we have one IGenerator2 which calls like standard CommonGenerator. Now we want to create second generator for json file with CommonLineageGenerator.

I have read several threads now were i found the following

component = org.eclipse.xtext.generator.GeneratorComponent {
register = CommonStandaloneSetup{}
outlet = {
path = "${runtimeProject}/src-gen"
}
}

component = org.eclipse.xtext.generator.GeneratorComponent {
register = CommonStandaloneSetup2{}
outlet = {
path = "${runtimeProject}/src-gen"
}
}

Where the StandaloneSetup contains an override of the Igenerator2 bindings

return Guice.createInjector(new CommonRuntimeModule())

return Guice.createInjector(new CommonRuntimeModule() {
override Class<? extends IGenerator2> bindIGenerator2() {
return CommonTracingGenerator;
}
});

We are also using mwe2 , to generate our language configuration.

When executing our compilation it now seems although that he is only taking one Generator. Is there anyway we can accomplish this. A wrapper is also possibility but we really want to avoid of mixing the two types of generations.

kr
Re: Multiple Generator calls on Xtext language [message #1841500 is a reply to message #1841475] Wed, 19 May 2021 07:35 Go to previous message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 176
Registered: July 2009
Location: Canada
Senior Member
Hi Thomas,

Having you simply tried calling the two generators from within the main/generated generator class? This is what I mean - https://gist.github.com/nbhusare/14c514225f3a4150cc33b355463f9180





Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
Previous Topic:Update to Java 11 as minimal Java version
Next Topic:Git / Maven Setup for standalone build
Goto Forum:
  


Current Time: Sun Sep 19 05:50:35 GMT 2021

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

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

Back to the top