public interface INode
A node in the parse tree. Clients will usually deal with fully initialized nodes thus the expected behavior and described contracts are only valid if the data structure's invariant is fulfilled.
Nodes may be considered immutable from a clients perspective. However, clients should never keep a reference to a node as it may be invalidated at any time and the very same object could be reused in another subtree of the full parse tree.
Modifier and Type | Method and Description |
---|---|
BidiTreeIterable<INode> |
getAsTreeIterable()
Returns a tree iterable that uses this node as its origin and root instance.
|
int |
getEndLine()
Returns the line number relative to the complete input where the node ends
(one based, excluding hidden tokens).
|
org.eclipse.emf.ecore.EObject |
getGrammarElement()
Returns the grammar element that created this node.
|
java.lang.Iterable<ILeafNode> |
getLeafNodes()
Returns an iterable for all contained leaf nodes.
|
int |
getLength()
Returns the length of this node excluding hidden tokens.
|
INode |
getNextSibling()
Returns the next sibling or
null . |
int |
getOffset()
Returns the offset of this node excluding hidden tokens.
|
ICompositeNode |
getParent()
Returns the parent of the node or
null if and only if this is the root node. |
INode |
getPreviousSibling()
Returns the previous sibling or
null . |
ICompositeNode |
getRootNode()
Returns the root node of this parse tree.
|
org.eclipse.emf.ecore.EObject |
getSemanticElement()
Returns the nearest semantic object that is associated with the subtree of this node.
|
int |
getStartLine()
Returns the line number relative to the complete input where the node begins
(one based, excluding hidden tokens).
|
SyntaxErrorMessage |
getSyntaxErrorMessage()
Returns the directly associated syntax error message or
null if none. |
java.lang.String |
getText()
Returns the parsed text that is covered by this node (including hidden tokens).
|
int |
getTotalEndLine()
Returns the line number relative to the complete input where the node ends
(one based, including hidden tokens).
|
int |
getTotalEndOffset()
Returns the end offset (exclusive) of this node including hidden tokens.
|
int |
getTotalLength()
Returns the length of this node including hidden tokens.
|
int |
getTotalOffset()
Returns the offset of this node including hidden tokens.
|
int |
getTotalStartLine()
Returns the line number relative to the complete input where the node begins
(one based, including hidden tokens).
|
boolean |
hasDirectSemanticElement()
Returns
true if this node as a directly associated semantic element. |
boolean |
hasNextSibling()
Returns
true if this node is not the last child of its parent. |
boolean |
hasPreviousSibling()
Returns
true if this node is not the first child of its parent. |
boolean |
hasSiblings()
Returns
true if this node has any siblings. |
ICompositeNode getParent()
null
if and only if this is the root node.null
.boolean hasSiblings()
true
if this node has any siblings.true
if this node has any siblings.hasPreviousSibling()
,
hasNextSibling()
boolean hasPreviousSibling()
true
if this node is not the first child of its parent.true
if this node has a previous sibling thus getPreviousSibling()
will
not return null
.boolean hasNextSibling()
true
if this node is not the last child of its parent.true
if this node has a next sibling thus getNextSibling()
will
not return null
.INode getPreviousSibling()
null
. The result has the same parent
as this node if it is not null
.null
.hasPreviousSibling()
,
hasSiblings()
INode getNextSibling()
null
.hasNextSibling()
,
hasSiblings()
ICompositeNode getRootNode()
null
in a consistent tree.null
in a consistent tree.java.lang.Iterable<ILeafNode> getLeafNodes()
null
.null
.int getTotalOffset()
int getOffset()
int getTotalLength()
int getLength()
int getTotalEndOffset()
offset
+
length
but may be more efficient.int getTotalStartLine()
int getStartLine()
int getTotalEndLine()
int getEndLine()
java.lang.String getText()
null
but may be empty.null
.org.eclipse.emf.ecore.EObject getGrammarElement()
null
in case of unrecoverable syntax
errors. This happens usually when a keyword occurred at an unexpected offset.null
.org.eclipse.emf.ecore.EObject getSemanticElement()
null
whenever
the parser refused to create any objects due to unrecoverable errors. Implementations will usually walk up the
node tree to find the semantic object. As the node model structure does not reflect the containment structure of
the semantic object graph, clients should usually use the utilities in
NodeModelUtils
to
obtain the semantic instance.null
.hasDirectSemanticElement()
,
NodeModelUtils.findActualSemanticObjectFor(INode)
boolean hasDirectSemanticElement()
true
if this node as a directly associated semantic element.true
if this node as a directly associated semantic element.getSemanticElement()
SyntaxErrorMessage getSyntaxErrorMessage()
null
if none.null
.BidiTreeIterable<INode> getAsTreeIterable()
BidiTreeIterator.previous()
or BidiTreeIterator.next()
will be this instance.