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 Detail

      • getModuleId

        @NotNull
        SModuleId getModuleId()
        The repository-wide unique identifier
      • getModuleName

        @Nullable
        String getModuleName()
        Identical to getModuleReference.getModuleName()
      • 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]
      • getUsedLanguages

        Set<SLanguage> getUsedLanguages()
        Returns all used languages by this module
      • 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), use 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.
      • getModels

        @NotNull
        default Collection<SModel> getModels​(@NotNull
                                             Predicate<SModel> condition)
        Filtered view of getModels() 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
      • 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, use getFacets() instead and filter as appropriate.
      • addModuleListener

        void addModuleListener​(SModuleListener listener)
        Listener can be added only once, the second time it's just not added
      • removeModuleListener

        void removeModuleListener​(SModuleListener listener)