Package jetbrains.mps.extapi.module
Class SModuleBase
- java.lang.Object
-
- jetbrains.mps.extapi.module.SModuleBase
-
- All Implemented Interfaces:
SModule
- Direct Known Subclasses:
AbstractModule
public abstract class SModuleBase extends Object implements SModule
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<SModel>MODEL_BY_NAME_COMPARATOR
-
Constructor Summary
Constructors Modifier Constructor Description protectedSModuleBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddModuleListener(SModuleListener listener)Listener can be added only once, the second time it's just not addedprotected voidassertCanChange()protected voidassertCanRead()voidattach(SRepository repo)voiddispose()voidfireBeforeModelRenamed(SModelBase model, SModelReference newName)Note: this method must not be used, except from within the model implementation classes.protected voidfireChanged()voidfireModelRenamed(SModelBase model, SModelReference oldName)Note: this method must not be used, except from within the model implementation classes.protected voidfireModuleRenamed(SModuleReference oldRef)SModelgetModel(SModelId id)FIXME document whether this method required model read Retrieves a module's model by idList<SModel>getModels()Retrieves all module's models.SRepositorygetRepository()The repository module has been registered with.voidregisterModel(SModelBase model)voidremoveModuleListener(SModuleListener listener)voidunregisterModel(SModelBase model)-
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.SModule
getDeclaredDependencies, getFacet, getFacets, getModelRoots, getModels, getModuleId, getModuleName, getModuleReference, getUsedLanguages, getUsedLanguageVersion, isPackaged, isReadOnly
-
-
-
-
Field Detail
-
MODEL_BY_NAME_COMPARATOR
public static final Comparator<SModel> MODEL_BY_NAME_COMPARATOR
-
-
Method Detail
-
getRepository
public final SRepository getRepository()
Description copied from interface:SModuleThe repository module has been registered with. Note, you can rely on non-nullvalue to indicate module is still in the repository only if you do so during model read/write. Otherwise, if you ask for module's repository outside of model lock, you may get stale value, e.g. if some other thread detach the module from the repository, so that in your thread:SRepository repo = module.getRepository(); repo.getModelAccess().runReadAction(() -> { SModule actualModule = repo.resolve(module.getModuleReference()); if (actualModule == null) { // legitimate case, module's repo might become stale if obtained outside of model lock } } );- Specified by:
getRepositoryin interfaceSModule
-
getModels
@NotNull public final List<SModel> getModels()
Description copied from interface:SModuleRetrieves all module's models. Note, there could be models intended for MPS internal needs (like '@descriptor' model), useSModule.getModels(Predicate)if you care about specific subset of models. Contract: if the module was not changed the order of the models which this method returns stays the same.
-
attach
public void attach(@NotNull SRepository repo)
-
dispose
public void dispose()
-
addModuleListener
public final void addModuleListener(SModuleListener listener)
Description copied from interface:SModuleListener can be added only once, the second time it's just not added- Specified by:
addModuleListenerin interfaceSModule
-
removeModuleListener
public final void removeModuleListener(SModuleListener listener)
- Specified by:
removeModuleListenerin interfaceSModule
-
fireChanged
protected final void fireChanged()
-
fireModuleRenamed
protected final void fireModuleRenamed(SModuleReference oldRef)
-
fireBeforeModelRenamed
public void fireBeforeModelRenamed(SModelBase model, SModelReference newName)
Note: this method must not be used, except from within the model implementation classes.
-
fireModelRenamed
public void fireModelRenamed(SModelBase model, SModelReference oldName)
Note: this method must not be used, except from within the model implementation classes.
-
getModel
public SModel getModel(SModelId id)
Description copied from interface:SModuleFIXME document whether this method required model read Retrieves a module's model by id
-
registerModel
public void registerModel(SModelBase model)
-
unregisterModel
public void unregisterModel(SModelBase model)
-
assertCanRead
protected void assertCanRead()
-
assertCanChange
protected void assertCanChange()
-
-