Xtext multiple generators
Asked Answered
S

1

6

I use Xtext plugin for eclipse to define my language and generate some files from it. The project is big and I would like to use multiple generators to generate my files, in addition to default generator, generated by the plugin.

I tried this solution http://www.eclipse.org/forums/index.php/t/263021/, but it don't work, looks like it related to old version of Xtext.

For example I have by default

class com.company.mylang.generator.MylangGenerator implements IGenerator {...}

I need to add other one

class com.company.mylang.generator.MylangGenerator2 implements IGenerator {...}

that runs as part of eclipse build.

Slipcase answered 26/2, 2014 at 9:48 Comment(0)
A
6

A composite generator could work. Your MylangGenerator could be implemented as a composite and delegate to the other generators, probably depending on some configuration or state in the resource.

class MylangCompositeGenerator implements IGenerator {

  @Inject MylangGenerator gen
  @Inject MylangGenerator2 gen2

  def doGenerate(Resource input, IFileSystemAccess fsa) {
    gen.doGenerator(input, fsa)
    gen2.doGenerator(input, fsa)
  }

}
Alkyd answered 26/2, 2014 at 10:30 Comment(1)
I have a similar problem. both my grammars are with separate extensions. however, only "gen" gets called for the generator for the files for MylangGenerator but never get called on the files for MylangGenerator2. Do you have any idea what could i be missing?Csch

© 2022 - 2024 — McMap. All rights reserved.