TextGen Aspect¶ ⧉
The TextGen language aspect defines a model-to-text transformation.
— MPS documentation
How do you get the TextGen for a node?
Use the classTextGeneratorEngine ⧉. It only works for root nodes such as ClassConcept ⧉ and returns null when no text output exists.
Can you also generate the text from the generator aspect?
Use the language com.dslfoundry.plaintextgen from MPS Extensions ⧉.
Can I implement text generation for another language?
I want to implement text generation for language A in a separate language B. I need different text generation for some of the KernelF concepts. When I try to do this, I get a compile error because it looks like the generated descriptor does not include "inherited" concepts:
Is it not possible to "override the textgen" this way?
asked by: @markusvoelter
It's not possible this way. So far, the two ways I have found to make this happen are:
-
Extend the original language (A.ex) and create subconcepts of all the concepts you need to specialize the textgen. You will then need to do M2M transformation to replace the extended concepts. You can do this generically by using a script. The generator that searches for all nodes of concepts that are extended in A.ex and replaces them by using the
RefactoringRuntime.replaceWithNewConcept
method. -
Create annotations that override the text generation of the concepts and attach them in a generator. TThen MPS will first call the annotation's text gen, and you can override it there.
There is MPS-22092 ⧉ which describes this request.
answered by: @coolya
Which built-in languages do not use the generator but only text generation?
- jetbrains.mps.baseLanguage.javadoc
- jetbrains.mps.core.properties
- jetbrains.mps.core.xml