Using light quotations in TextGen?
I am trying to harness the power of light quotations when generating text. Here is my textgen component:
MapEntry has a textgen component associated with it. I am using no generators, just textgen.
With the light quotations in use, the model checker reports this issue:
And indeed when I try to go through with the build, I get errors:
What am I doing wrong here?
EDIT: it seems I'm getting a Java exception while this code is being typechecked, and I didn't notice. I don't think this is the direct cause for this issue, but I might as well bring it up: https://youtrack.jetbrains.com/issue/MPS-33181
Please sign in to leave a comment.
The quotation language is not included in the genplan for the textgen aspect model so the nodes with lightweight quotations remain unchanged and so the generation fails.
However, even if the genplan included the quotation language your approach would not be working since the generated model is read-only in the textgen phase and so you cannot add or change nodes during the textgen phase.
I eventually just moved the quotations to a helper class in another model, which works, but the model checker still reports that error, which I now have to ignore. Bit of a bug right there.
Anyways, I'm disappointed that MPS lacks the ability to do what I want directly. It's not intuitive at all that using quotations would break textgen. Thanks for telling me what I was trying was impossible, though.
I guess one of my hardest achievements was to remember the META LEVEL I am on.... MPS is so sweet that I tend to forget it from time to time.
To find out why lang.quotation is still in generation plan for your textgen aspect, try 'Show Generation Plan' action from the model's context menu. There'd be a list of all involved generators, with a reversed list of where they came from (e.g. through extension/generation target/direct use, etc).
Indeed, with quotations moved to another model, the code would work - each model have distinct generation plan, and the one for the model includes lang.quotation, while genplan for the model that describes textgen aspect does not. As Vaclav pointed out, you could not modify input model, but as long as you use quotations to populate just a list of detached nodes, there's no issue with that, one can create nodes and add them into collection. However, with this approach you open up to a lot of other possible issues. First, a lot of other textgen code doesn't expect to get a node that is not part of a model (like the nodes you've just constructed and iterate over in `append`). Second, you may not have proper TextGen components for nodes you create. The moment TextGen process starts, it may look for used languages in a model, and restrict itself to respective textgen aspects of these languages only. Languages of concepts referenced by light quotations are not considered as 'used' (it's rather a direct reference to structure model), and if you happen to create a concept that belongs to a language not among used by a model, you may face errors due to missing textgen components for the concept (let alone you may create concepts of a language that doesn't have textgen aspect at all).
Is there any strong reason to perform M2M operations during textgen? Textgen deemed to be quite straightforward M2T transformation, use of quotations there is not that common.