Using java.util.collections classes in generator
I am trying to create a generator that outputs java code for my language, but I'm running into the problem that I can't figure out how to use a java.util.collections class (LinkedList / ArrayList etc). MPS lets me put linkedlist as the type for a generated node, but then there is no textgen for that, which makes me believe I am mis-using that type (same with map). What do I need to do in order to have my generated java code using arraylist etc?
Thanks
(I searched the forum for other things related to this issue but could not find a post that spelled out exactly what I am either misunderstanding or doing wrong)
Thanks
(I searched the forum for other things related to this issue but could not find a post that spelled out exactly what I am either misunderstanding or doing wrong)
Please sign in to leave a comment.
Furthermore, in MPS2.0 Generator/properties/common accepts jars only... So I should import the sdk itself in my model! Which is inconsistent since the SDK itself has been modelized in baseLanguage :-/
Please could you help me on this, here is the real errors:
For,
And
For,
Evgeny Gryaznov was kind enough to give a solution.
http://forum.jetbrains.com/thread/Meta-Programming-System-632
Plz feel free to contact me if you need further help.
The expected generation workflow:
1. apply your generator (which produces collections)
2. reduce collections language -> java collections api
3. save to .java
In terms of languages:
[program in your language] —> [in baseLanguage + collections]
—> [in baseLanguage] —> .java files
But since you didn't specify that your language produces collection language, your generator could be inserted at random step. The workflow could look like:
1. reduce collections language -> java collections api
2. apply your generator (produces collections which will never be reduced)
3. save to .java (failure, non-java elements found)
The solution:
Add a priority rule (see Generator -> Properties) that your generator is <= than collections generator.