Package jetbrains.mps.smodel
Class SNode
- java.lang.Object
 - 
- jetbrains.mps.smodel.SNode
 
 
- 
- All Implemented Interfaces:
 SNode
- Direct Known Subclasses:
 InterfaceSNode,LazySNode
public class SNode extends Object implements SNode
As a tribute to legacy code, we do allow access to constant and meta-info objects of a node without read access. It's not encouraged for a new code, though, and might change in future, that's why it's stated here and not in openapi.SNode 
- 
- 
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddChild(String role, SNode child)Deprecated.voidaddChild(SContainmentLink role, SNode child)Adds a new child as a last child in a given role.protected voidassertCanRead()protected voidchildren_insertBefore(SNode anchor, SNode node)protected voidchildren_remove(SNode node)voiddelete()Deletes all nodes in subtree starting with current.protected SNodefirstChild()List<SNode>getChildren()Returns an immutable collection of all children.List<SNode>getChildren(String role)Deprecated.List<SNode>getChildren(SContainmentLink role)Returns an immutable collection of children in the specified role.SConceptgetConcept()The concept that this node represents.SNodegetContainingRoot()Returns the ancestor of current node, which parent is null Does not produce read on current as current is already obtainedSContainmentLinkgetContainmentLink()Returns role of this node in parent node Returns null if a node has no parentSNodegetFirstChild()Works together with getLastChild().SNodegetLastChild()Works together with getFirstChild().SModelgetModel()Containing model or null if the node is not contained in any model Does not produce node read event as the function depending on model is not a pure node function.StringgetName()For instances of INamedConcept concepts retrieves "name" propertySNodegetNextSibling()no parent -> no sibling.SNodeIdgetNodeId()Uniquely identifies the node within its containing model.SNodegetParent()Returns the parent of this node Does not produce read on current as current is already obtained, does notify read for the parent.StringgetPresentation()A string representing the node used to show the node in UISNodegetPrevSibling()no parent -> no sibling.Iterable<SProperty>getProperties()Retrieves keys of all properties.StringgetProperty(String propertyName)Deprecated.StringgetProperty(SProperty property)Returns the value of this propertyCollection<String>getPropertyNames()Deprecated.SNodeReferencegetReference()Uniquely identifies the node in a repository.SReferencegetReference(String role)Deprecated.SReferencegetReference(SReferenceLink role)Retrieves an SReference of the given role to a node.List<SReference>getReferences()Retrieves all SReferences from the node.SNodegetReferenceTarget(String role)Deprecated.SNodegetReferenceTarget(SReferenceLink role)Null means the reference has not been set or was set to null.StringgetRoleInParent()Deprecated.ObjectgetUserObject(Object key)Iterable<Object>getUserObjectKeys()booleanhasProperty(String propertyName)Deprecated.booleanhasProperty(SProperty property)voidinsertChildAfter(SContainmentLink role, SNode child, SNode anchor)Inserts the given node as a child of the current node of the specified role right after the anchor node.voidinsertChildBefore(String role, SNode child, SNode anchor)Deprecated.voidinsertChildBefore(SContainmentLink role, SNode child, SNode anchor)Inserts the given node as a child of the current node of the specified role right in front of the anchor node.booleanisInstanceOfConcept(SAbstractConcept c)voidputUserObject(Object key, Object value)voidremoveChild(SNode child)Removes child from current node.voidsetId(SNodeId id)voidsetProperty(String propertyName, String propertyValue)Deprecated.voidsetProperty(SProperty property, String propertyValue)Sets the value of the raw property.voidsetReference(String role, SReference reference)Deprecated.voidsetReference(SReferenceLink role, SReference toAdd)Sets a reference of the given role to a node that is resolved from the SReference.voidsetReferenceTarget(String role, SNode target)Deprecated.voidsetReferenceTarget(SReferenceLink role, SNode target)Sets a reference of the given role to a particular nodeStringtoString()SNodetreeNext()protected SNodetreeParent()protected SNodetreePrevious() 
 - 
 
- 
- 
Method Detail
- 
getConcept
@NotNull public SConcept getConcept()
Description copied from interface:SNodeThe concept that this node represents. Concepts can be checked for equality with equals().- Specified by:
 getConceptin interfaceSNode
 
- 
isInstanceOfConcept
public boolean isInstanceOfConcept(@NotNull SAbstractConcept c)
- Specified by:
 isInstanceOfConceptin interfaceSNode
 
- 
insertChildAfter
public void insertChildAfter(@NotNull SContainmentLink role, @NotNull SNode child, @Nullable SNode anchor)
Description copied from interface:SNodeInserts the given node as a child of the current node of the specified role right after the anchor node.- Specified by:
 insertChildAfterin interfaceSNode- Parameters:
 role- a role to insert new child intochild- a node to insertanchor- a new child node will be inserted just after this node. If anchor is not specified, a new child is inserted as a first child. If anchor is the last child element, newly added child becomes tail of collection
 
- 
assertCanRead
protected final void assertCanRead()
 
- 
getNodeId
public SNodeId getNodeId()
Description copied from interface:SNodeUniquely identifies the node within its containing model. May also be null. Does not produce node read event as the result value can't be changed. 
- 
getContainingRoot
@NotNull public SNode getContainingRoot()
Description copied from interface:SNodeReturns the ancestor of current node, which parent is null Does not produce read on current as current is already obtained- Specified by:
 getContainingRootin interfaceSNode- Returns:
 - root containing this node
 
 
- 
getName
public String getName()
Description copied from interface:SNodeFor instances of INamedConcept concepts retrieves "name" property 
- 
getParent
public final SNode getParent()
Description copied from interface:SNodeReturns the parent of this node Does not produce read on current as current is already obtained, does notify read for the parent. 
- 
removeChild
public void removeChild(@NotNull SNode child)
Removes child from current node. This affects only link between current node and its child, but not links in subtree of child node. Differs fromdelete(). FIXME please explain how it differs from delete()- Specified by:
 removeChildin interfaceSNode- Parameters:
 child-
 
- 
delete
public void delete()
Deletes all nodes in subtree starting with current. Differs fromremoveChild(org.jetbrains.mps.openapi.model.SNode). 
- 
getPresentation
public String getPresentation()
Description copied from interface:SNodeA string representing the node used to show the node in UI- Specified by:
 getPresentationin interfaceSNode
 
- 
getReference
@NotNull public SNodeReference getReference()
Description copied from interface:SNodeUniquely identifies the node in a repository. Never changes between subsequent read and write actions and behaves as a "weak reference" for a node Represents the only correct way to pass or store nodes between read/write actions. Does not produce node read event as the node is already obtained, and the read event has already happened. If obtained for a node that is not in repository, can return invalid reference- Specified by:
 getReferencein interfaceSNode
 
- 
getUserObject
public Object getUserObject(Object key)
- Specified by:
 getUserObjectin interfaceSNode
 
- 
putUserObject
public void putUserObject(Object key, @Nullable Object value)
- Specified by:
 putUserObjectin interfaceSNode
 
- 
getChildren
@NotNull public List<SNode> getChildren()
Description copied from interface:SNodeReturns an immutable collection of all children. Read access policy is same to getChildren(role)- Specified by:
 getChildrenin interfaceSNode
 
- 
getReferences
@NotNull public List<SReference> getReferences()
Description copied from interface:SNodeRetrieves all SReferences from the node. Since SReference can refer to nodes by name and resolve them dynamically, this method may be able to help you resolve the target nodes even when working with invalid code. The returned collection is immutable. Produces read access on the node.- Specified by:
 getReferencesin interfaceSNode
 
- 
getFirstChild
public SNode getFirstChild()
Description copied from interface:SNodeWorks together with getLastChild(). Allows to iterate through a collection of all children.- Specified by:
 getFirstChildin interfaceSNode- Returns:
 - first element in a collection of children
 
 
- 
getLastChild
public SNode getLastChild()
Description copied from interface:SNodeWorks together with getFirstChild(). Allows to iterate through a collection of all children.- Specified by:
 getLastChildin interfaceSNode- Returns:
 - last element in a collection of children
 
 
- 
getPrevSibling
public SNode getPrevSibling()
Description copied from interface:SNodeno parent -> no sibling. Root has no siblings Does not produce read on current as current is already obtained Notifies read for the parent node and sibling node, if any.- Specified by:
 getPrevSiblingin interfaceSNode
 
- 
getNextSibling
public SNode getNextSibling()
Description copied from interface:SNodeno parent -> no sibling. Root has no siblings Does not produce read on current as current is already obtained. Notifies read for the parent node and sibling node, if any.- Specified by:
 getNextSiblingin interfaceSNode
 
- 
getUserObjectKeys
public Iterable<Object> getUserObjectKeys()
- Specified by:
 getUserObjectKeysin interfaceSNode
 
- 
getModel
public SModel getModel()
Description copied from interface:SNodeContaining model or null if the node is not contained in any model Does not produce node read event as the function depending on model is not a pure node function.- Specified by:
 getModelin interfaceSNode- See Also:
 SNodeAccessListener
 
- 
firstChild
protected SNode firstChild()
 
- 
treePrevious
protected SNode treePrevious()
 
- 
treeNext
public SNode treeNext()
 
- 
treeParent
protected SNode treeParent()
 
- 
getContainmentLink
public SContainmentLink getContainmentLink()
Description copied from interface:SNodeReturns role of this node in parent node Returns null if a node has no parent- Specified by:
 getContainmentLinkin interfaceSNode
 
- 
hasProperty
public boolean hasProperty(@NotNull SProperty property)
- Specified by:
 hasPropertyin interfaceSNode
 
- 
getProperty
public String getProperty(@NotNull SProperty property)
Description copied from interface:SNodeReturns the value of this property- Specified by:
 getPropertyin interfaceSNode- Returns:
 - value of a property or null if the property was not set
 
 
- 
setProperty
public void setProperty(@NotNull SProperty property, String propertyValue)
Description copied from interface:SNodeSets the value of the raw property. Constraints are not checked.- Specified by:
 setPropertyin interfaceSNode
 
- 
getProperties
@NotNull public Iterable<SProperty> getProperties()
Description copied from interface:SNodeRetrieves keys of all properties. The returned collection is immutable.- Specified by:
 getPropertiesin interfaceSNode
 
- 
setReferenceTarget
public void setReferenceTarget(@NotNull SReferenceLink role, @Nullable SNode target)
Description copied from interface:SNodeSets a reference of the given role to a particular node- Specified by:
 setReferenceTargetin interfaceSNode
 
- 
getReferenceTarget
public SNode getReferenceTarget(@NotNull SReferenceLink role)
Description copied from interface:SNodeNull means the reference has not been set or was set to null. It's impossible to the distinguish the two cases.- Specified by:
 getReferenceTargetin interfaceSNode
 
- 
getReference
public SReference getReference(@NotNull SReferenceLink role)
Description copied from interface:SNodeRetrieves an SReference of the given role to a node. Since SReference can refer to nodes by name and resolve them dynamically, this method may be able to help you resolve the target node even when working with invalid code.- Specified by:
 getReferencein interfaceSNode
 
- 
setReference
public void setReference(@NotNull SReferenceLink role, SReference toAdd)
Description copied from interface:SNodeSets a reference of the given role to a node that is resolved from the SReference. Since SReference can refer to nodes by name and resolve them dynamically, this method may be able to resolve the target node even when working with invalid code.- Specified by:
 setReferencein interfaceSNode
 
- 
insertChildBefore
public void insertChildBefore(@NotNull SContainmentLink role, @NotNull SNode child, @Nullable SNode anchor)
Description copied from interface:SNodeInserts the given node as a child of the current node of the specified role right in front of the anchor node.- Specified by:
 insertChildBeforein interfaceSNode- Parameters:
 role- a role to insert new child intochild- a node to insertanchor- a new child node will be inserted just before this node. If anchor is not specified, a new child is inserted as a last child. If anchor is the first child element, newly added child becomes head of collection
 
- 
addChild
public void addChild(@NotNull SContainmentLink role, @NotNull SNode child)
Description copied from interface:SNodeAdds a new child as a last child in a given role. 
- 
getChildren
@NotNull public List<SNode> getChildren(SContainmentLink role)
Description copied from interface:SNodeReturns an immutable collection of children in the specified role. Does not produce read on current as current is already obtained, produces read accesses to child nodes lazily (when really accessed), does not produce read accesses for skipped children- Specified by:
 getChildrenin interfaceSNode
 
- 
getRoleInParent
@Deprecated public String getRoleInParent()
Deprecated.- Specified by:
 getRoleInParentin interfaceSNode
 
- 
hasProperty
@Deprecated public final boolean hasProperty(String propertyName)
Deprecated.- Specified by:
 hasPropertyin interfaceSNode
 
- 
getProperty
@Deprecated public final String getProperty(String propertyName)
Deprecated.- Specified by:
 getPropertyin interfaceSNode
 
- 
setProperty
@Deprecated public void setProperty(String propertyName, String propertyValue)
Deprecated.- Specified by:
 setPropertyin interfaceSNode
 
- 
getPropertyNames
@Deprecated public Collection<String> getPropertyNames()
Deprecated.- Specified by:
 getPropertyNamesin interfaceSNode
 
- 
setReferenceTarget
@Deprecated public void setReferenceTarget(String role, @Nullable SNode target)
Deprecated.- Specified by:
 setReferenceTargetin interfaceSNode
 
- 
getReferenceTarget
@Deprecated public SNode getReferenceTarget(String role)
Deprecated.- Specified by:
 getReferenceTargetin interfaceSNode
 
- 
getReference
@Deprecated public SReference getReference(String role)
Deprecated.- Specified by:
 getReferencein interfaceSNode
 
- 
setReference
@Deprecated public void setReference(String role, @Nullable SReference reference)
Deprecated.- Specified by:
 setReferencein interfaceSNode
 
- 
insertChildBefore
@Deprecated public void insertChildBefore(@NotNull String role, SNode child, @Nullable SNode anchor)
Deprecated.- Specified by:
 insertChildBeforein interfaceSNode
 
- 
addChild
@Deprecated public void addChild(String role, SNode child)
Deprecated. 
- 
getChildren
@Deprecated @NotNull public List<SNode> getChildren(String role)
Deprecated.- Specified by:
 getChildrenin interfaceSNode
 
 - 
 
 -