A generator stub is automatically created by Xtext. In our example, the stub is created in the org.example.entities.generator
package:
class EntitiesGenerator extends AbstractGenerator { override void doGenerate(Resource res, IFileSystemAccess2 fsa, IGeneratorContext context) { // TODO implement me } }
Before writing the actual code, let's recall that Xtext is a framework; thus, the overall flow of control is dictated by the framework, not by the programmer. This is also known as the Hollywood Principle: Don't call us, we'll call you. This means that you do not have to manually run the generator. Your DSL Xtext editor is already integrated in the automatic building infrastructure of Eclipse, and the generator will be automatically called when a source written in your DSL changes. Indeed, it will be called also if one of its dependencies changes, as we will see in later chapters.
Note that the method you have to implement...