programmatically add used language (or dependency) to existing model

Hi,

I'm generating models programmatically and filling the up with content also programmatically. However I am having trouble adding used languages programmatically (I do not know the languages used by the model in advance). I have tried using the Open API and this code I found linked to the used guide:

// adding used language to a module
AbstractModule internalModule = (AbstractModule) sModule;
internalModule.getModuleDescriptor().getUsedLanguages().add(module reference/jetbrains.mps.baseLanguage/);

However this does not work. I'm using MPS 3.4.1 and there actually the getUsedLanguages method is deprecated.

Thank you!

Levi.

7 comments
Comment actions Permalink

Used languages on module level are automatically updated. You have to add them to the models only.

0
Comment actions Permalink

Thanks, Sascha, adding the language to the model worked fine! For reference, here is the code I used:

SModel outModel = root.createModel("outputModel.results"); 
SModelInternal internalOutModel = (SModelInternal) outModel;
internalOutModel.addLanguage(outputLanguage); 

Where outputLanguage is of type SLanguage

Cheers,

Levi.

1
Comment actions Permalink

Hi,

Am a newbie to MPS. My usecase is almost similar to the above mentioned

So anyone let me know how to retrieve the "Slanguage" ?

 

Regards

Deepak P

0
Comment actions Permalink

Hi Deepak,

Sorry, I didn't understand your question. Do you mean you want to add SLanguage to a model programatically? 

Best,

Levi.

0
Comment actions Permalink

Hi,

Yes, I need to add programmatically a language dependency as shown in the attachment.

 

 

Deepak P

0
Comment actions Permalink

You can just type "language/.../". The concept of this expression is jetbrains.mps.lang.smodel.LanguageRefExpression.

1
Comment actions Permalink

Thanks a lot ... :) it worked ...

0

Please sign in to leave a comment.