Interface SModel

  • All Known Subinterfaces:
    EditableSModel

    public interface SModel
    Represents a model. Models are loaded lazily when needed.
    • Method Detail

      • getModelId

        @NotNull
        SModelId getModelId()
        Returns the id of the model valid within the containing module.
      • getModelName

        @Deprecated
        String getModelName()
        Deprecated.
        Prefer getName() with access to distinct fractions of the name
        This is an equivalent to getModelReference().getModelName The returned name of the model may include a stereotype, such as 'generator' or 'tests', separated by the '@' character, e.g. jetbrains.mps.sample.generator.main@generator
      • getName

        @NotNull
        SModelName getName()
        This is an equivalent to getModelReference().getName()
        Returns:
        name of the model in its full glory
      • getModule

        SModule getModule()
        Retrieves the owning module TODO: fix remove SModule!
      • getRootNodes

        Iterable<SNode> getRootNodes()
        Returns a collection of root nodes. Root nodes are all nodes added to model using addRootNode. todo VP: should be immutable collection? Currently it isn't.
      • createNode

        SNode createNode​(@NotNull
                         SConcept concept)
        Instantiates an SNode of the given concept, suitable for use in this model.
      • addRootNode

        void addRootNode​(SNode node)
        Adds the node as a root to this model. Each node in the underlying subtree becomes connected to this model and returns it from the getModel() method.
        Throws:
        jetbrains.mps.smodel.IllegalModelChangeError - when invoked on a read-only model or outside of a valid command.
      • removeRootNode

        void removeRootNode​(SNode node)
        Removes the whole subtree from the model.
        Throws:
        jetbrains.mps.smodel.IllegalModelChangeError - when invoked on a read-only model or outside of a valid command.
      • getSource

        @NotNull
        DataSource getSource()
        The data source which this model was loaded from.
      • isReadOnly

        boolean isReadOnly()
        No changes are permitted. For read-only models all modification operations always throw jetbrains.mps.smodel.IllegalModelChangeError.
      • isLoaded

        boolean isLoaded()
        The model is fully loaded into memory.
      • load

        void load()
        When owning a read action lock, this method will fully load the model from the storage. Does nothing if already loaded. The load() method is called automatically on a not-loaded model whenever elements from it are being resolved. Problems can be retrieved later by the getProblems() method.
      • getProblems

        @NotNull
        Iterable<SModel.Problem> getProblems()
        The list of persistence-specific model problems (like syntax or I/O errors). Returns empty list if this model is not loaded yet.
      • unload

        void unload()
        Tries to reduce memory footprint. The implementation might be no-op for certain subclasses. The invariant is: after accessing model that was previously unloaded, the model should be observed as before unloading to some extent. E.g. EditableSModel should appear the same to the user after unload/access operations performed. Requires write action, this method may discard the in-memory representation of the model.
      • addAccessListener

        void addAccessListener​(SNodeAccessListener l)
        Parameters:
        l - listener to add, tolerates null
        Since:
        3.3
      • removeAccessListener

        void removeAccessListener​(SNodeAccessListener l)
        Parameters:
        l - listener to remove, tolerates null
        Since:
        3.3
      • addChangeListener

        void addChangeListener​(SNodeChangeListener l)
        As SNode API suggests, any model could be modified. However, it's up to model's implementation to decide whether to send notifications about changes or not. Attaching a change listener to a model doesn't guarantee changes get dispatched to the listener, unless it's a model that explicitly states that as part of its contract (e.g. EditableSModel). Note, there's no guarantee about listener uniqueness, i.e. it's unspecified what happens if the same listener instance is added twice.
        Parameters:
        l - listener to add, tolerates null
        Since:
        3.3
      • removeChangeListener

        void removeChangeListener​(SNodeChangeListener l)
        Parameters:
        l - listener to remove, tolerates null and unknown (not registered) listeners
        Since:
        3.3