The Java generator should be considered "just one of the generators". Instead, it's currently tightly coupled to our RosettaGenerator, which is responsible for generating code for all available generators. The distinction between our Java generator and external generators leads to several issues.
To address these issues, I propose the following:
Provide a consistent interface for all code generators (Java's and the "external" ones), which is only a small wrapper around Xtext's IGenerator2. It exposes the following methods:
Inject a single implementation of the above generator inside our RosettaGenerator, which can then generate code with it only for that code generator. Generating code for different languages can then be done by creating a Guice module that provides the right implementation. (solves https://github.com/REGnosys/rosetta-dsl/issues/526)
Provide a single way of accessing project version information through the IGeneratorContext, i.e., by subclassing it with RosettaGeneratorContext:
public interface RosettaGeneratorContext extends IGeneratorContext {
public String getProjectVersion();
}
The RosettaGeneratorContext should also contain a name (e.g. common-domain-model or digitial-regulatory-reporting etc) as this is required in some scenarios (e.g. specified in the .toml file in python).
The Java generator should be considered "just one of the generators". Instead, it's currently tightly coupled to our
RosettaGenerator
, which is responsible for generating code for all available generators. The distinction between our Java generator and external generators leads to several issues.To address these issues, I propose the following:
Provide a consistent interface for all code generators (Java's and the "external" ones), which is only a small wrapper around Xtext's
IGenerator2
. It exposes the following methods:(solves https://github.com/REGnosys/rosetta-dsl/issues/527)
Inject a single implementation of the above generator inside our
RosettaGenerator
, which can then generate code with it only for that code generator. Generating code for different languages can then be done by creating a Guice module that provides the right implementation. (solves https://github.com/REGnosys/rosetta-dsl/issues/526)Provide a single way of accessing project version information through the
IGeneratorContext
, i.e., by subclassing it withRosettaGeneratorContext
:(addresses issues encountered while developing a Python generator - see discussion here: https://github.com/REGnosys/rosetta-code-generators/pull/204#discussion_r1178049334)