Package org.jetbrains.mps.openapi.model
Interface SModel
-
- All Known Subinterfaces:
EditableSModel
public interface SModelRepresents a model. Models are loaded lazily when needed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceSModel.ProblemRepresents a problem with the persistence.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidaddAccessListener(SNodeAccessListener l)voidaddChangeListener(SNodeChangeListener l)AsSNodeAPI suggests, any model could be modified.voidaddModelListener(SModelListener l)voidaddRootNode(SNode node)Adds the node as a root to this model.SNodecreateNode(SConcept concept)Instantiates an SNode of the given concept, suitable for use in this model.SNodecreateNode(SConcept concept, SNodeId nodeId)Instantiates an SNode of the given concept, suitable for use in this model, optionally specifying an id for the node.SModelIdgetModelId()Returns the id of the model valid within the containing module.StringgetModelName()Deprecated.PrefergetName()with access to distinct fractions of the nameModelRootgetModelRoot()SModulegetModule()Retrieves the owning module TODO: fix remove SModule!SModelNamegetName()This is an equivalent togetModelReference().getName()SNodegetNode(SNodeId id)Iterable<SModel.Problem>getProblems()The list of persistence-specific model problems (like syntax or I/O errors).SModelReferencegetReference()SRepositorygetRepository()Iterable<SNode>getRootNodes()Returns a collection of root nodes.DataSourcegetSource()The data source which this model was loaded from.booleanisLoaded()The model is fully loaded into memory.booleanisReadOnly()No changes are permitted.voidload()When owning a read action lock, this method will fully load the model from the storage.voidremoveAccessListener(SNodeAccessListener l)voidremoveChangeListener(SNodeChangeListener l)voidremoveModelListener(SModelListener l)voidremoveRootNode(SNode node)Removes the whole subtree from the model.voidunload()Tries to reduce memory footprint.
-
-
-
Method Detail
-
getRepository
SRepository getRepository()
-
getModelId
@NotNull SModelId getModelId()
Returns the id of the model valid within the containing module.
-
getModelName
@Deprecated String getModelName()
Deprecated.PrefergetName()with access to distinct fractions of the nameThis 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 togetModelReference().getName()- Returns:
- name of the model in its full glory
-
getReference
@NotNull SModelReference getReference()
-
getModelRoot
ModelRoot getModelRoot()
-
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.
-
createNode
SNode createNode(@NotNull SConcept concept, @Nullable SNodeId nodeId)
Instantiates an SNode of the given concept, suitable for use in this model, optionally specifying an id for the node. If nonodeIdwas supplied, the call is identical tocreateNode(org.jetbrains.mps.openapi.language.SConcept)
-
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 throwjetbrains.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 thegetProblems()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.
-
addModelListener
void addModelListener(SModelListener l)
-
removeModelListener
void removeModelListener(SModelListener l)
-
addAccessListener
void addAccessListener(SNodeAccessListener l)
- Parameters:
l- listener to add, toleratesnull- Since:
- 3.3
-
removeAccessListener
void removeAccessListener(SNodeAccessListener l)
- Parameters:
l- listener to remove, toleratesnull- Since:
- 3.3
-
addChangeListener
void addChangeListener(SNodeChangeListener l)
AsSNodeAPI 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, toleratesnull- Since:
- 3.3
-
removeChangeListener
void removeChangeListener(SNodeChangeListener l)
- Parameters:
l- listener to remove, toleratesnulland unknown (not registered) listeners- Since:
- 3.3
-
-