TextGen - multiple files output per single concept instance.


Is it possible, in TextGen, to generate multiple files per root node?

E.g. from a root node named "some-root-node", I would like to generate such files:
  • SomeRootNode.java
  • SomeRootNode.cpp
  • SomeRootNode.h

Is it possible with TextGen?

The above example actually needs two things:
1. generating multiple files per root node
2. having file name different than root node name

Regarding "1.": is it possible at all with TextGen?
When I add a second text gen component for the same concept, only one of them actually works... The other one seems ignored.

Regarding "2.": someone suggested, that I could have some build target passing over all nodes and changing their "name" property. But this seems a bit unwieldy.
Since there is already a way to specify file extension in TextGen, wouldn't it also be possible to specify file name (as an expression returning string), right next to the extension?
Are there any plans to add such a possibility?

If I have to create a build facet from scratch, instead of using TextGen, then what "resources policy" do I have to set in build targets?
Currently I'm experimenting with "transform (module, models) MResource -> <no output>". Should I have TResource as output? Is it ok to just use FileOutputStream and write to files directly or shall I use some higher abstraction?
What before/after dependencies would you suggest?
Currently I have:
        after configure
        before generate

But with those parameters and with using FileOutputStream directly, my generated files appear only exactly every second rebuild, which is very surprising.
I thought that rebuild is supposed to start from a clean state and not depend on previous build.
But the files show up exactly every second time and disappear every other time. Weird.
Please advise what could be the cause and whether using FileOutputStream even makes sense.

I was using this tutorial - http://confluence.jetbrains.com/display/MPSD30/HowTo+--+Integrating+into+the+MPS+Make+Framework but there were some troubles, for example I had to use MResource instead of IMResource. So is this tutorial still up to date?

I'm using MPS 3.0 from March 3rd 2014.

By the way, what is the current status of GText (presented in http://tv.jetbrains.net/videocontent/mps-basics-gtext-generation ) ?

Thank You,
1 comment
Comment actions Permalink
As far as I know, I'm a newbie, the answer to question 1 is "No". MPS suppose you first create a model of the language you want to generate, as it's already implemented for Java/BaseLanguage. Then you generate the root node, in your example, for a .cpp file and the root node for a .h file, with model-to-model transformations. Finally these root nodes a translated to text with TextGen.

Please sign in to leave a comment.