Package jetbrains.mps.project
Class ProjectRepository
- java.lang.Object
 - 
- jetbrains.mps.extapi.module.SRepositoryBase
 - 
- jetbrains.mps.project.ProjectRepository
 
 
 
- 
- All Implemented Interfaces:
 SRepositoryExt,ReferenceScopeHelper.Source,SRepository
public class ProjectRepository extends SRepositoryBase implements SRepositoryExt, ReferenceScopeHelper.Source
Repository with modules visible in MPSproject. IMPORTANT! For the time being, all modules available in this MPS instance are exposed through this repository, although as we move forward with multiple projects story, this convention shall change. Likely, we'll expose modules of the project and all its imports/libraries (and won't expose modules of other opened projects), though this is not yet final. Currently delegates almost everything to the ugly singletonMPSModuleRepository. Keeps own list of listeners and sends out own notifications about modules added/removed (i.e. module added to the global repository triggers moduleAdded for for both global and each project repository 
- 
- 
Constructor Summary
Constructors Constructor Description ProjectRepository(Project project, SRepositoryExt rootRepo, SRepositoryRegistry repositoryRegistry)ProjectRepository(Project project, SRepositoryExt rootRepo, SRepositoryRegistry repositoryRegistry, ModelAccess projectModelAccess) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRepositoryListener(SRepositoryListener listener)Register a listener for the repository.ModelAccessgetModelAccess()SModulegetModule(SModuleId ref)Iterable<SModule>getModules()Returns an unmodifiable collection of modules.Set<SModule>getModules(MPSModuleOwner moduleOwner)Set<MPSModuleOwner>getOwners(SModule module)ProjectgetProject()ReferenceScopeHelpergetReferenceScopeHelper()<T extends SModule>
TregisterModule(T module, MPSModuleOwner owner)Need register/unregister API for modules because at the moment registration goes through static instance ofMPSModuleRepository.voidremoveRepositoryListener(SRepositoryListener listener)Remove a listener.voidsaveAll()voidunregisterModule(SModule module, MPSModuleOwner owner)Unregisters given module only (e.g.- 
Methods inherited from class jetbrains.mps.extapi.module.SRepositoryBase
dispose, fireBeforeModuleRemoved, fireCommandFinished, fireCommandStarted, fireModuleAdded, fireModuleRemoved, getParent, getRepositoryAccess, init 
- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Methods inherited from interface org.jetbrains.mps.openapi.module.SRepository
getParent, getRepositoryAccess 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
ProjectRepository
public ProjectRepository(@NotNull Project project, @NotNull SRepositoryExt rootRepo, @Nullable SRepositoryRegistry repositoryRegistry)
 
- 
ProjectRepository
public ProjectRepository(@NotNull Project project, @NotNull SRepositoryExt rootRepo, @Nullable SRepositoryRegistry repositoryRegistry, @NotNull ModelAccess projectModelAccess)
 
 - 
 
- 
Method Detail
- 
getProject
public Project getProject()
 
- 
getModule
public SModule getModule(@NotNull SModuleId ref)
- Specified by:
 getModulein interfaceSRepository- Returns:
 - the module which id is equal to the given module id.
 A repository is able to have only one module for a given module id.
 
nullis returned iff there is no such module in the repository 
 
- 
getModules
@NotNull public Iterable<SModule> getModules()
Description copied from interface:SRepositoryReturns an unmodifiable collection of modules.- Specified by:
 getModulesin interfaceSRepository
 
- 
getModelAccess
@NotNull public ModelAccess getModelAccess()
- Specified by:
 getModelAccessin interfaceSRepository- Returns:
 - a special class which yields a control to the objects which comprise the repository. These are namely modules, models, model roots, nodes.
 
 
- 
saveAll
public void saveAll()
- Specified by:
 saveAllin interfaceSRepository
 
- 
registerModule
public <T extends SModule> T registerModule(@NotNull T module, @NotNull MPSModuleOwner owner)
Description copied from interface:SRepositoryExtNeed register/unregister API for modules because at the moment registration goes through static instance ofMPSModuleRepository. Not an API right away due to (a) MPSModuleOwner is not an API; (b) not certain whether we shall have separate 'editable' SRepository interface (like EditableSModel), which sounds rather stupid but it's the way it runs in the rest of MPS, or the API shall become part of SRepository, but this rises a question if the API shall fail in a harsh or silent way for repositories that do not support change (c) I don't like return value for the method, but it's the way MPSModuleRepository have it. I don't quite buy "single module in a repo, with multiple *owners*" story. If it's truly needed, we could accomplish the same with register(getModule(moduleRef), anotherOwner), rather than return value Promise: once returns, module is attached to the repositoryMPSModuleRepository.registerModule(SModule, MPSModuleOwner)- Specified by:
 registerModulein interfaceSRepositoryExt
 
- 
unregisterModule
public void unregisterModule(@NotNull SModule module, @NotNull MPSModuleOwner owner)
Description copied from interface:SRepositoryExtUnregisters given module only (e.g. in case of a language, it's not repository responsibility to care about language generators) 
- 
getOwners
public Set<MPSModuleOwner> getOwners(@NotNull SModule module)
- Specified by:
 getOwnersin interfaceSRepositoryExt
 
- 
getModules
public Set<SModule> getModules(MPSModuleOwner moduleOwner)
- Specified by:
 getModulesin interfaceSRepositoryExt
 
- 
addRepositoryListener
public void addRepositoryListener(@NotNull SRepositoryListener listener)
Description copied from interface:SRepositoryRegister a listener for the repository. If a listener isSRepositoryAttachListener, it gets additionally notified and can perform own initialization (e.g. handle modules already in the repository)- Specified by:
 addRepositoryListenerin interfaceSRepository- Overrides:
 addRepositoryListenerin classSRepositoryBase
 
- 
removeRepositoryListener
public void removeRepositoryListener(@NotNull SRepositoryListener listener)
Description copied from interface:SRepositoryRemove a listener. If a listener isSRepositoryAttachListener, it is notified of detach event.- Specified by:
 removeRepositoryListenerin interfaceSRepository- Overrides:
 removeRepositoryListenerin classSRepositoryBase
 
- 
getReferenceScopeHelper
public ReferenceScopeHelper getReferenceScopeHelper()
- Specified by:
 getReferenceScopeHelperin interfaceReferenceScopeHelper.Source
 
 - 
 
 -