Package org.jetbrains.mps.openapi.model
Class SNodeUtil
- java.lang.Object
-
- org.jetbrains.mps.openapi.model.SNodeUtil
-
public class SNodeUtil extends Object
This class implement complex operations on the node structure. Unlike the SNode implementations, which may focus on their specific needs, this class should consider all cases, e.g. replacing a node with a root node from another model
-
-
Constructor Summary
Constructors Constructor Description SNodeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Iterable<SNode>
getDescendants(Iterable<SNode> roots)
Iterate over subtrees of each node in a given sequence of 'root' nodesstatic Iterable<SNode>
getDescendants(SModel model)
Iterates over all nodes in the given model.static Iterable<SNode>
getDescendants(SNode node)
Iterates over the subtree starting at the given node.static Iterable<SNode>
getDescendants(SNode node, Condition<SNode> condition, boolean includeFirst)
Iterates over the subtree starting at the given node.static boolean
isAccessible(SNode node, SRepository inRepository)
Returns whether the given node belongs to the repository (or to one of its parent repositories).static boolean
isInstanceOf(SNode node, SAbstractConcept concept)
For non-null node,SNode.isInstanceOfConcept(SAbstractConcept)
is straightforward replacementstatic SNode
replaceWithAnother(SNode node, SNode replacer)
Replaces a node with another, preserving attributes
-
-
-
Method Detail
-
isAccessible
public static boolean isAccessible(@NotNull SNode node, @NotNull SRepository inRepository)
Returns whether the given node belongs to the repository (or to one of its parent repositories).
-
isInstanceOf
public static boolean isInstanceOf(@Nullable SNode node, @NotNull SAbstractConcept concept)
For non-null node,SNode.isInstanceOfConcept(SAbstractConcept)
is straightforward replacement
-
replaceWithAnother
public static SNode replaceWithAnother(@NotNull SNode node, SNode replacer)
Replaces a node with another, preserving attributes
-
getDescendants
public static Iterable<SNode> getDescendants(@NotNull SModel model)
Iterates over all nodes in the given model.
-
getDescendants
@NotNull public static Iterable<SNode> getDescendants(@NotNull SNode node)
Iterates over the subtree starting at the given node.
-
getDescendants
@NotNull public static Iterable<SNode> getDescendants(@NotNull SNode node, @Nullable Condition<SNode> condition, boolean includeFirst)
Iterates over the subtree starting at the given node.- Parameters:
condition
- if not null, acts like a filterincludeFirst
- false to skip the root node from the returned sequence
-
-