Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xtext multiple generators

Tags:

xtext

xtend

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.

like image 471
Hersh Avatar asked Feb 26 '14 09:02

Hersh


1 Answers

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

}
like image 172
Sebastian Zarnekow Avatar answered Jan 03 '23 23:01

Sebastian Zarnekow