Hey, I have a root component A which has B as a child (B has a TextGen aspect and can also be a root, but isn't in this instance). I would like to generate (Java) code for A and use the text file gene...
This is an auto-generated question from the MPS Slack community: Hey, I have a root component A which has B as a child (B has a TextGen aspect and can also be a root, but isn't in this instance). I would like to generate (Java) code for A and use the text file generated by B within the Java code for A. How could I go about that?
I found this comment here https://mps-support.jetbrains.com/hc/en-us/community/posts/115000539884/comments/360000103079 by a user named 'Nandha', but I don't know how to obtain B's `SNode` within the java class generation template of A.
5 comments
Sort by
Date
Votes
Isn't it done automatically for you? AFAIK MPS will use the generator to transform the model and in the end will use TextGen on the last model to produce text, so if your B node is still present at that point, it will get converted to text.
Thanks for you reply. Hm. I'll try to explain again, because I'm not sure if I explained myself correctly.
Suppose I have node A, implementing `IMainClass`, which is transformed into a Java program. One of A's child nodes is B which could also be an independent root node. What I would like to have as 'output' is the following:
`.` (output directory)
`./textGenBOutput/BText.txt`
`./GeneratedProgramBasedOnA.java`
So that the Java program is able to read the generated text via a `FileInputStream` or something similar and to some processing based on that.
Maybe I took a wrong turn somewhere, but I did not manage to achieve this.
You can use a preprocessing script in the generator to detach all B nodes that have a parent and add them as roots to the input model (or instead of detaching them, add their copies to the input model).
Ok thanks, I will try that
This is auto-generated question from the MPS Community Slack Workspace. If you want to comment on the question, do it from the Slack workspace
Post is closed for comments.