Using model & module dependencies FAQ
model m = node.model;
SModel sModel = m;
model m2 = sModel;
SModelInternal internalSModel = (SModelInternal) sModel;
SModule sModule = sModel.getModule();
SRepository sRepository = sModel.getRepository();
Iterable<SModule> modules = sRepository.getModules();
SModule module = sRepository.getModule(sModule.getModuleId());
SModule closuresRuntimeModule = sRepository.getModule(
module reference
/closures.runtime/.getModuleId());
if
(module
instanceof
Language) {
Language language = (Language) module;
}
Language mpsBaseLanguage = (Language)
module
/jetbrains.mps.baseLanguage/;
sequence
<SDependency> dependencies = m
module.getDeclaredDependencies()
AbstractModule internalModule = (AbstractModule) sModule;
internalModule.getModuleDescriptor().getUsedLanguages().add(
module reference
/jetbrains.mps.baseLanguage/);
sequence
<Dependency> internalDependencies = internalModule.getModuleDescriptor().getDependencies();
sequence
<SModuleReference> usedModuleReferences = internalDependencies.select({~it => it.getModuleRef(); });
internalModule.getModuleDescriptor().getDependencies().add(
new
Dependency(
module reference
/closures.runtime/,
SDependencyScope. DEFAULT , false
));
internalModule.getModuleDescriptor().getUsedDevkits().add(
module reference
/jetbrains.mps.devkit.general-purpose/);
Iterable<SModel> models = sModule.getModels();
sModule.getModel(sModel.getModelId());
internalSModel.importedModels();
internalSModel.addModelImport(sModel.getReference(),
false
);
internalSModel.deleteModelImport(sModel.getReference());
internalSModel.importedLanguages();
internalSModel.addLanguage(mpsBaseLanguage.getModuleReference());
internalSModel.addLanguage(
module reference
/jetbrains.mps.baseLanguage/);
internalSModel.importedDevkits();
internalSModel.addDevKit(
module reference
/jetbrains.mps.devkit.general-purpose/);
internalSModel.deleteDevKit(
module reference
/jetbrains.mps.devkit.general-purpose/);