Class SModuleBase

    • Field Detail

      • MODEL_BY_NAME_COMPARATOR

        public static final Comparator<SModel> MODEL_BY_NAME_COMPARATOR
    • Constructor Detail

      • SModuleBase

        protected SModuleBase()
    • Method Detail

      • getRepository

        public final SRepository getRepository()
        Description copied from interface: SModule
        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
             }
           } );
         
        Specified by:
        getRepository in interface SModule
      • getModels

        @NotNull
        public final List<SModel> getModels()
        Description copied from interface: SModule
        Retrieves all module's models. Note, there could be models intended for MPS internal needs (like '@descriptor' model), use SModule.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.
        Specified by:
        getModels in interface SModule
      • dispose

        public void dispose()
      • addModuleListener

        public final void addModuleListener​(SModuleListener listener)
        Description copied from interface: SModule
        Listener can be added only once, the second time it's just not added
        Specified by:
        addModuleListener in interface SModule
      • 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: SModule
        FIXME document whether this method required model read Retrieves a module's model by id
        Specified by:
        getModel in interface SModule
      • registerModel

        public void registerModel​(SModelBase model)
      • unregisterModel

        public void unregisterModel​(SModelBase model)
      • assertCanRead

        protected void assertCanRead()
      • assertCanChange

        protected void assertCanChange()