Package org.jetbrains.mps.openapi.module
Interface SModule
-
public interface SModule
A module is an abstraction for collection of models, tailored to address specific task. Examples of a module include Language module to provide new DSL capabilities into MPS, Generator module to describe transformation between lanuages, and a Solution module, which serves various purposes ranging from language runtime support to end-user code.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addModuleListener(SModuleListener listener)
Listener can be added only once, the second time it's just not addedIterable<SDependency>
getDeclaredDependencies()
All dependencies on modules of all kinds.default <T extends SModuleFacet>
TgetFacet(Class<T> clazz)
Returns facet of the specified class.default SModuleFacet
getFacetOfType(String type)
Iterable<SModuleFacet>
getFacets()
Retrieves all instantiated facets.SModel
getModel(SModelId id)
FIXME document whether this method required model read Retrieves a module's model by idIterable<ModelRoot>
getModelRoots()
Iterable<SModel>
getModels()
Retrieves all module's models.default Collection<SModel>
getModels(Predicate<SModel> condition)
Filtered view ofgetModels()
with models matching supplied conditionSModuleId
getModuleId()
The repository-wide unique identifierString
getModuleName()
Identical to getModuleReference.getModuleName()SModuleReference
getModuleReference()
A reference to the module, which persists between subsequent read/write actions.SRepository
getRepository()
The repository module has been registered with.Set<SLanguage>
getUsedLanguages()
Returns all used languages by this moduleint
getUsedLanguageVersion(SLanguage usedLanguage)
Returns version of used languageboolean
isPackaged()
The module has been imported as a compiled library, not sources.boolean
isReadOnly()
No updates are permittedvoid
removeModuleListener(SModuleListener listener)
-
-
-
Method Detail
-
getModuleReference
@NotNull SModuleReference getModuleReference()
A reference to the module, which persists between subsequent read/write actions.
-
isReadOnly
boolean isReadOnly()
No updates are permitted
-
isPackaged
boolean isPackaged()
The module has been imported as a compiled library, not sources. Implies read only.
-
getRepository
@Nullable SRepository getRepository()
The repository module has been registered with. Note, you can rely on non-null
value 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 } } );
-
getDeclaredDependencies
Iterable<SDependency> getDeclaredDependencies()
All dependencies on modules of all kinds. Includes only dependencies declared in this model. See also GlobalModuleDependenciesManager [not yet in API]
-
getUsedLanguageVersion
int getUsedLanguageVersion(@NotNull SLanguage usedLanguage)
Returns version of used language
-
getModel
@Nullable SModel getModel(SModelId id)
FIXME document whether this method required model read Retrieves a module's model by id
-
getModels
@NotNull Iterable<SModel> getModels()
Retrieves all module's models. Note, there could be models intended for MPS internal needs (like '@descriptor' model), usegetModels(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.
-
getModels
@NotNull default Collection<SModel> getModels(@NotNull Predicate<SModel> condition)
Filtered view ofgetModels()
with models matching supplied condition- Parameters:
condition
- tells whether a model is allowed to pass- Returns:
- subset of module's own models that match the condition
-
getFacets
@NotNull Iterable<SModuleFacet> getFacets()
Retrieves all instantiated facets. (seeSModuleFacet
)
-
getFacet
@Nullable default <T extends SModuleFacet> T getFacet(@NotNull Class<T> clazz)
Returns facet of the specified class. If there is more than one facet instance that conforms specified class, it's unspecified which one is returned, usegetFacets()
instead and filter as appropriate.
-
getFacetOfType
@Nullable default SModuleFacet getFacetOfType(@NotNull String type)
-
addModuleListener
void addModuleListener(SModuleListener listener)
Listener can be added only once, the second time it's just not added
-
removeModuleListener
void removeModuleListener(SModuleListener listener)
-
-