The SModel interface (
org.jetbrains.mps.openapi.model.SModel) contains methods for querying and modifying nodes
contained in a model but methods to modify the dependencies of a model (model imports or used languages) are absent.
There’s another interface called
jetbrains.mps.smodel.SModelInternal that has these methods but is there any way to
modify the dependency information without resorting to internal APIs?
It turns out there is an undocumented but public class named ModelImports (
which is intended as a public facade to the dependency information. To use it, wrap the model in an instance of
model myModel = ...; new ModelImports(myModel).addModelImport(model-ptr/my.imported.model/);
The class can be used to query, add, or remove model imports, used languages and devkits.