Package jetbrains.mps.smodel
Class ModuleRepositoryFacade
- java.lang.Object
 - 
- jetbrains.mps.smodel.ModuleRepositoryFacade
 
 
- 
- All Implemented Interfaces:
 CoreComponent
public final class ModuleRepositoryFacade extends Object implements CoreComponent
Mediator between API aspects of an SRepository and our implementation aspects, like SRepositoryExt. Use this class to avoid casts to SRepositoryExt IMPORTANT: lifespan of a facade instance shall not last longer than single model read. Implementation may cache values (e.g. model name to model instance) to answer subsequent queries faster, and may not reflect changes made to a repository. 
- 
- 
Constructor Summary
Constructors Constructor Description ModuleRepositoryFacade(Project mpsProject)ModuleRepositoryFacade(MPSModuleRepository repo)Deprecated.This class shall cease to be CoreComponent and singleton.ModuleRepositoryFacade(SRepository repository)Some methods of this facade are bound to implementation-specificSRepositoryExtandMPSModuleOwnerinterfaces Unless you use them, you're safe to pass anySRepositoryinstance here. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static SModulecreateModule(ModulesMiner.ModuleHandle handle, MPSModuleOwner owner)Deprecated.use instance counterpartinstantiateModule(ModuleHandle, MPSModuleOwner)instead.voiddispose()Collection<Language>getAllExtendingLanguages(Language l)Deprecated.If there's need for extending language, shall addLanguage.getDirectlyExtendingLanguage.Collection<SModel>getAllModels()Provisional API while we migrate from singleton SModelRepository.<T extends SModule>
Collection<T>getAllModules(Class<T> cls)static ModuleRepositoryFacadegetInstance()Deprecated.SModelgetModelByName(String modelQualifiedName)Deprecated.there could be more than 1 model with the same name, usegetModelsByName(SModelName)and pick the one you need.Collection<SModel>getModelsByName(SModelName modelName)Replacement forgetModelByName(String)that respects the case when models with the same name present (e.g.SModulegetModule(SModuleReference ref)<T extends SModule>
TgetModule(SModuleReference ref, Class<T> cls)Set<MPSModuleOwner>getModuleOwners(SModule module)<T extends SModule>
Collection<T>getModules(MPSModuleOwner moduleOwner, Class<T> cls)Collection<SModule>getModulesByName(String moduleName)Use only if there is no way to usegetModule(org.jetbrains.mps.openapi.module.SModuleReference)orSRepository.getModule(org.jetbrains.mps.openapi.module.SModuleId).
For example: check for existing modules with the same name on new module creation search module by name in user search dialog/popupSRepositorygetRepository()voidinit()SModuleinstantiateModule(ModulesMiner.ModuleHandle handle, MPSModuleOwner owner)Instantiate a new module according to description and register it with the facade's repository.voidunregisterModule(SModule module)unregisters module from all its ownersvoidunregisterModules(MPSModuleOwner owner) 
 - 
 
- 
- 
Constructor Detail
- 
ModuleRepositoryFacade
@Deprecated public ModuleRepositoryFacade(MPSModuleRepository repo)
Deprecated.This class shall cease to be CoreComponent and singleton. Instead, shall be instantiated directly withModuleRepositoryFacade(SRepository)when our implementation code need to deal with repository internals- Parameters:
 repo-
 
- 
ModuleRepositoryFacade
public ModuleRepositoryFacade(@NotNull SRepository repository)
Some methods of this facade are bound to implementation-specificSRepositoryExtandMPSModuleOwnerinterfaces Unless you use them, you're safe to pass anySRepositoryinstance here. If, however, you need to register/unregister modules, make sure repository you pass is instance ofSRepositoryExt- Parameters:
 repository- container for modules as described above
 
 - 
 
- 
Method Detail
- 
init
public void init()
- Specified by:
 initin interfaceCoreComponent
 
- 
dispose
public void dispose()
- Specified by:
 disposein interfaceCoreComponent
 
- 
getInstance
@Deprecated public static ModuleRepositoryFacade getInstance()
Deprecated.Please use one of the constructors instead 
- 
getRepository
public SRepository getRepository()
- Returns:
 - repository this facade has been initialized with, never 
null - Since:
 - 2017.2
 
 
- 
getModule
public SModule getModule(@NotNull SModuleReference ref)
 
- 
getModule
public <T extends SModule> T getModule(SModuleReference ref, Class<T> cls)
 
- 
getAllModules
public <T extends SModule> Collection<T> getAllModules(Class<T> cls)
 
- 
getModules
public <T extends SModule> Collection<T> getModules(MPSModuleOwner moduleOwner, @Nullable Class<T> cls)
 
- 
getModelByName
@Nullable @Deprecated public SModel getModelByName(@Nullable String modelQualifiedName)
Deprecated.there could be more than 1 model with the same name, usegetModelsByName(SModelName)and pick the one you need. This is provisional API to keep all uses of SModelRepository.getModelDescriptor(String) in a single, controlled place. I could had had created ModelRepositoryFacade, similar to this class, however, it seems just too much for a single method that we shall drop anyway.- Parameters:
 modelQualifiedName-- Returns:
 - named model
 
 
- 
getModelsByName
@NotNull public Collection<SModel> getModelsByName(@Nullable SModelName modelName)
Replacement forgetModelByName(String)that respects the case when models with the same name present (e.g. in different modules). Generally, accessing models by name is nad idea, you shall preferSModelReferenceto access specific model. There are certain scenarios, though, when we need to access by name, therefore we keep this utility method in a facade class. Note, implementation of this method is ineffective now, as it iterates over all modules and models of a repository.- Parameters:
 modelName- exact name (qualified, with stereotype, if any) of the model to match- Returns:
 - all models with the same exact name, or empty collection if none found
 
 
- 
getModulesByName
@NotNull public Collection<SModule> getModulesByName(@NotNull String moduleName)
Use only if there is no way to use
getModule(org.jetbrains.mps.openapi.module.SModuleReference)orSRepository.getModule(org.jetbrains.mps.openapi.module.SModuleId).
For example:- check for existing modules with the same name on new module creation
 - search module by name in user search dialog/popup
 
- Returns:
 - collection of modules which names are equal to the given module name. A repository is able to have several modules for a given module name. Empty collection is returned iff there are no such modules in the repository.
 - Since:
 - 2017.2
 
 
- 
getAllModels
public Collection<SModel> getAllModels()
Provisional API while we migrate from singleton SModelRepository. Likely, SModelRepository would become a view of an SRepository, giving access to models and bulk operations for the set of models.- Returns:
 - snapshot state of the models available in the repository
 
 
- 
getAllExtendingLanguages
@Deprecated public Collection<Language> getAllExtendingLanguages(Language l)
Deprecated.If there's need for extending language, shall addLanguage.getDirectlyExtendingLanguage. There's single use in mbeddr.Find language modules directly extending the one supplied. There'sLanguage.getAllExtendedLanguages()extended languages. Though it's stupid to keep two locations, this method didn't relocate next to it as there are no uses in MPS and it shall cease to exist 
- 
unregisterModules
public void unregisterModules(MPSModuleOwner owner)
 
- 
unregisterModule
public void unregisterModule(@NotNull SModule module)
unregisters module from all its owners 
- 
getModuleOwners
public Set<MPSModuleOwner> getModuleOwners(SModule module)
 
- 
instantiateModule
@NotNull public SModule instantiateModule(@NotNull ModulesMiner.ModuleHandle handle, @NotNull MPSModuleOwner owner)
Instantiate a new module according to description and register it with the facade's repository. If there's module already (expected scenario), just updates its relation to another module owner (same module could get published with few owners)- Returns:
 - instance of a module, either new one or existing from the facade's repository.
 - Throws:
 IllegalArgumentException- if handle describes unknown module kind.
 
- 
createModule
@Deprecated public static SModule createModule(ModulesMiner.ModuleHandle handle, MPSModuleOwner owner)
Deprecated.use instance counterpartinstantiateModule(ModuleHandle, MPSModuleOwner)instead. 
 - 
 
 -