1

I am trying to understand how code generator doGenerate invokes. I took an example Xtext Project without any custom changes (only Greetings). By Default code generator looks like this:

override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
    fsa.generateFile('greetings.txt', 'People to greet: ' + 
        resource.allContents
            .filter(Greeting)
            .map[name]
            .join(', '))
}

After I ran the Generated Eclipse Plug-in and created new Java Project with file in /src with right extention (src.MyDsl). and converted project to xtext nature, I wrote some greetings and saved. But in src-gen I did not see generated file greetings.txt. So Interpreter works but does not save code.

I have found in Question: xtext-dogenerate method is not called that the file, where I want to save code, needs the right file extension (case sensitive) --(done), the project - xtext nature --(done) and build automatically needs to be enabled.

My Question is how can I enable it to use doGenerate Code Generator automatically? So I could see generated code in greetings.txt

grüBer
  • 25
  • 4

1 Answers1

1

you have to make sure

  • your model project has Xtext nature and builder (right-click, configure) - you should be asked if you open the file
  • you have build automatically enabled
  • if the model project is a java project model files should be in a source folder
  • the file extension is correct (case sensitive) src.MyDsl looks suspicious in that regards
Christian Dietrich
  • 11,778
  • 4
  • 24
  • 32
  • OOOPs! thank u so much, with src.mydsl it works. I have got it. I have done a mistake in extention... just no words :) – grüBer Jun 14 '19 at 14:12