Post processing classes

Hi.

Is it possible to postprocess generated classes?
My usecase is to add "@Generated" annotation to every class generated by MPS.
3 comments
Comment actions Permalink
Hi Dmitry,

one solution is to have another generator model "BM" which runs after your current generator model (check "Show mapping partitioning" for generator priorities). You can write a pre-processing script in BM which gets all ClassConcepts, e.g. model.roots(ClassConcept) and adds an annotation.

Be sure to set "modifies model" in your prepro script.

Best,
Dan
0
Comment actions Permalink
Dmitry,

You can also integrate into make-process by writing a "facet" in plugin model of your language that will run "before make" and "after compile". This will allow fully-custom processing for generated code/classes/other artifacts.

Regards,
Mihail
0
Comment actions Permalink
It is better to use post-processing script. Create a separate mapping configuration with a post-processing script. It should be applied when everything is reduced to baseLanguage. So, add priority: your mapping configuration = baseLanguage.
0

Please sign in to leave a comment.