Question

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.

Was it helpful?

Solution

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

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top