baseLanguage Generator Issues
I am using the baseLanguage as the target for code generation. While doing this come across have several issues. Not sure whether these are limitations of MPS, or of my knowledge of MPS.
- In the generated Java text files, there are no imports statements. As a result these files do not compile. Is there a way to get the imports in the output?
- The package name of the Java classes is defined by the model name. As I am working with business people as users of my language, I'd like to be able to change this. I have found the following long-running issue for this: http://youtrack.jetbrains.com/issue/MPS-5962?projectKey=MPS
- I cannot find any way to set the root output folder of the generator. All code is generated in the same project as the model, but I'd like to generate to some other location. is this possible?
Please sign in to leave a comment.
2) Currently it's a limitation of MPS. I'm not sure that referenced issue properly describes the problem which you are facing. To my understanding it's more about generating the model and being able to specify arbitrary package name for that model...
3) In the preferences of the Solution you should be able to modify property "Generator output path".
2) I will create an issue with a more precise description, then you can see whether it is the same.
1) Imports are not generated in specific circumstances:
Situation as floows:
Model:
Generator OK:
Java Output OK:
Same model
Generator:
Java Code without import:
If I refer to the BaseClass directly in the template the BaseClass is recognized and the import generated.
If I use a reference macro and return the string "BaseClass" the class is not recognized, and therefore the import is not generated.
in your case i suggest using second or third option if the target class can be generated by MPS and can be located in different model.
However, I have the same situation with two interfaces extending each other and get a baseLanguage textgen error when using option 4. I have created the following issue for this: http://youtrack.jetbrains.com/issue/MPS-19178. Tried option 3 as well, same result.
I am stuck for now.
In your situation, AFAIU, code generation & text generation were passed without any problems, but compilation process fails with "unresolved target classifier" problem which is reasonable - there is no target classifier.
referent : (outputNode, genContext, operationContext, node)->join(node<Classifier> | string) { if (node.model == node.ruleSetType.model) { return "com.i2s.ibml.core.base.generated.IBaseRuleSetTypeExtension"; } else { node<InternalClassifierType> result = new node<InternalClassifierType>(); result.fqClassName = node.ruleSetType.genJavaExtendedInterfaceNameFQN(); return result.classifier; // return node.ruleSetType.genJavaExtendedInterfaceNameFQN(); } }I first tried to return the node<InternalClassifier>, but that is not node<Classifier>, so I get a type error. Then I tried the above which gives an error message:
As the result.classifier is a node<Classifier> I added a typecast, but get the same error. I also tried to ignore the error message and it compiles without problems. However, the result when running the generator is failing. I get the following error messages and there is no code generated.
Can you explain how I should use the InternalClassifier to make it work ?