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.

Hersh
  • 630
  • 4
  • 16

1 Answers1

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)
  }

}
Sebastian Zarnekow
  • 6,609
  • 20
  • 23
  • 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? – Hamzawey Oct 28 '17 at 16:14