Interface INode
-
- All Known Subinterfaces:
ICompositeNode,ILeafNode
- All Known Implementing Classes:
AbstractNode,CompositeNode,CompositeNodeWithSemanticElement,CompositeNodeWithSemanticElementAndSyntaxError,CompositeNodeWithSyntaxError,HiddenLeafNode,HiddenLeafNodeWithSyntaxError,LeafNode,LeafNodeWithSyntaxError,RootNode,SyntheticCompositeNode
public interface INodeA 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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BidiTreeIterable<INode>getAsTreeIterable()Returns a tree iterable that uses this node as its origin and root instance.intgetEndLine()Returns the line number relative to the complete input where the node ends (one based, excluding hidden tokens).intgetEndOffset()Returns the end offset (exclusive) of this node excluding hidden tokens.org.eclipse.emf.ecore.EObjectgetGrammarElement()Returns the grammar element that created this node.java.lang.Iterable<ILeafNode>getLeafNodes()Returns an iterable for all contained leaf nodes.intgetLength()Returns the length of this node excluding hidden tokens.INodegetNextSibling()Returns the next sibling ornull.intgetOffset()Returns the offset of this node excluding hidden tokens.ICompositeNodegetParent()Returns the parent of the node ornullif and only if this is the root node.INodegetPreviousSibling()Returns the previous sibling ornull.ICompositeNodegetRootNode()Returns the root node of this parse tree.org.eclipse.emf.ecore.EObjectgetSemanticElement()Returns the nearest semantic object that is associated with the subtree of this node.intgetStartLine()Returns the line number relative to the complete input where the node begins (one based, excluding hidden tokens).SyntaxErrorMessagegetSyntaxErrorMessage()Returns the directly associated syntax error message ornullif none.java.lang.StringgetText()Returns the parsed text that is covered by this node (including hidden tokens).org.eclipse.xtext.util.ITextRegiongetTextRegion()org.eclipse.xtext.util.ITextRegionWithLineInformationgetTextRegionWithLineInformation()Returns aregion with line informationfor this node excluding hidden tokens: anoffsetof this region is the same as anoffsetof this node; alengthof this region is the same as alengthof this node; aline numberof this region is the same as astart lineof this node; anend line numberof this region is the same as anend lineof this node.intgetTotalEndLine()Returns the line number relative to the complete input where the node ends (one based, including hidden tokens).intgetTotalEndOffset()Returns the end offset (exclusive) of this node including hidden tokens.intgetTotalLength()Returns the length of this node including hidden tokens.intgetTotalOffset()Returns the offset of this node including hidden tokens.intgetTotalStartLine()Returns the line number relative to the complete input where the node begins (one based, including hidden tokens).org.eclipse.xtext.util.ITextRegiongetTotalTextRegion()Returns aregionfor this node including hidden tokens: anoffsetof this region is the same as atotal offsetof this node; and alengthof this region is the same as atotal lengthof this node.org.eclipse.xtext.util.ITextRegionWithLineInformationgetTotalTextRegionWithLineInformation()Returns aregion with line informationfor this node including hidden tokens: anoffsetof this region is the same as atotal offsetof this node; alengthof this region is the same as atotal lengthof this node; aline numberof this region is the same as atotal start lineof this node; anend line numberof this region is the same as atotal end lineof this node.booleanhasDirectSemanticElement()Returnstrueif this node as a directly associated semantic element.booleanhasNextSibling()Returnstrueif this node is not the last child of its parent.booleanhasPreviousSibling()Returnstrueif this node is not the first child of its parent.booleanhasSiblings()Returnstrueif this node has any siblings.
-
-
-
Method Detail
-
getParent
ICompositeNode getParent()
Returns the parent of the node ornullif and only if this is the root node.- Returns:
- the parent of this node or
null.
-
hasSiblings
boolean hasSiblings()
Returnstrueif this node has any siblings.- Returns:
trueif this node has any siblings.- See Also:
hasPreviousSibling(),hasNextSibling()
-
hasPreviousSibling
boolean hasPreviousSibling()
Returnstrueif this node is not the first child of its parent.- Returns:
trueif this node has a previous sibling thusgetPreviousSibling()will not returnnull.
-
hasNextSibling
boolean hasNextSibling()
Returnstrueif this node is not the last child of its parent.- Returns:
trueif this node has a next sibling thusgetNextSibling()will not returnnull.
-
getPreviousSibling
INode getPreviousSibling()
Returns the previous sibling ornull. The result has the sameparentas this node if it is notnull.- Returns:
- the previous sibling or
null. - See Also:
hasPreviousSibling(),hasSiblings()
-
getNextSibling
INode getNextSibling()
- Returns:
- the next sibling or
null. - See Also:
hasNextSibling(),hasSiblings()
-
getRootNode
ICompositeNode getRootNode()
Returns the root node of this parse tree. Will not returnnullin a consistent tree.- Returns:
- the root node of this parse tree. Will not return
nullin a consistent tree.
-
getLeafNodes
java.lang.Iterable<ILeafNode> getLeafNodes()
Returns an iterable for all contained leaf nodes. Nevernull.- Returns:
- an iterable for all contained leaf nodes. Never
null.
-
getTotalOffset
int getTotalOffset()
Returns the offset of this node including hidden tokens.- Returns:
- the offset of this node including hidden tokens.
-
getOffset
int getOffset()
Returns the offset of this node excluding hidden tokens. If this node is a hidden leaf node or a composite node that does only contain hidden leaf nodes, the total offset is returned.- Returns:
- the offset of this node excluding hidden tokens.
-
getTotalLength
int getTotalLength()
Returns the length of this node including hidden tokens.- Returns:
- the length of this node including hidden tokens.
-
getLength
int getLength()
Returns the length of this node excluding hidden tokens. If this node is a hidden leaf node, the total length is returned.- Returns:
- the length of this node excluding hidden tokens.
-
getTotalEndOffset
int getTotalEndOffset()
Returns the end offset (exclusive) of this node including hidden tokens. Yields the same result asoffset+lengthbut may be more efficient.- Returns:
- the end offset (exclusive) of this node including hidden tokens.
-
getEndOffset
int getEndOffset()
Returns the end offset (exclusive) of this node excluding hidden tokens. Yields the same result asoffset+lengthbut may be more efficient.- Returns:
- the end offset (exclusive) of this node excluding hidden tokens.
- Since:
- 2.5
-
getTotalStartLine
int getTotalStartLine()
Returns the line number relative to the complete input where the node begins (one based, including hidden tokens).- Returns:
- the line number relative to the complete input where the node begins.
-
getStartLine
int getStartLine()
Returns the line number relative to the complete input where the node begins (one based, excluding hidden tokens).- Returns:
- the line number relative to the complete input where the node begins.
-
getTotalEndLine
int getTotalEndLine()
Returns the line number relative to the complete input where the node ends (one based, including hidden tokens).- Returns:
- the line number relative to the complete input where the node ends.
-
getEndLine
int getEndLine()
Returns the line number relative to the complete input where the node ends (one based, excluding hidden tokens).- Returns:
- the line number relative to the complete input where the node ends.
-
getText
java.lang.String getText()
Returns the parsed text that is covered by this node (including hidden tokens). The result is nevernullbut may be empty.- Returns:
- the parsed text that is covered by this node (including hidden tokens). Never
null. - Throws:
java.lang.IllegalStateException- if the text is not available. A possible reason is, that the node is not part of a valid node model.
-
getGrammarElement
org.eclipse.emf.ecore.EObject getGrammarElement()
Returns the grammar element that created this node. May returnnullin case of unrecoverable syntax errors. This happens usually when a keyword occurred at an unexpected offset.- Returns:
- the grammar element that created this node. May return
null.
-
getSemanticElement
org.eclipse.emf.ecore.EObject getSemanticElement()
Returns the nearest semantic object that is associated with the subtree of this node. May returnnullwhenever 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 inNodeModelUtilsto obtain the semantic instance.- Returns:
- the nearest semantic object that is associated with the subtree of this node. May return
null. - See Also:
hasDirectSemanticElement(),NodeModelUtils.findActualSemanticObjectFor(INode)
-
hasDirectSemanticElement
boolean hasDirectSemanticElement()
Returnstrueif this node as a directly associated semantic element.- Returns:
trueif this node as a directly associated semantic element.- See Also:
getSemanticElement()
-
getSyntaxErrorMessage
SyntaxErrorMessage getSyntaxErrorMessage()
Returns the directly associated syntax error message ornullif none.- Returns:
- the directly associated syntax error message. May return
null.
-
getAsTreeIterable
BidiTreeIterable<INode> getAsTreeIterable()
Returns a tree iterable that uses this node as its origin and root instance. Its iterator will not return any siblings of this root. However, the first element returned byBidiTreeIterator.previous()orBidiTreeIterator.next()will be this instance.- Returns:
- a tree iterable where this node represents the root instance.
-
getTextRegion
org.eclipse.xtext.util.ITextRegion getTextRegion()
Returns a
regionfor this node excluding hidden tokens:- an
offsetof this region is the same as anoffsetof this node; - and a
lengthof this region is the same as alengthof this node.
This method could be more efficient than calculating an
offsetand alengthof this node separately.- Returns:
- a
regionfor this node excluding hidden tokens - Since:
- 2.5
- an
-
getTotalTextRegion
org.eclipse.xtext.util.ITextRegion getTotalTextRegion()
Returns a
regionfor this node including hidden tokens:- an
offsetof this region is the same as atotal offsetof this node; - and a
lengthof this region is the same as atotal lengthof this node.
This method could be more efficient than calculating a
total offsetand atotal lengthof this node separately.- Returns:
- a
regionfor this node including hidden tokens - Since:
- 2.5
- an
-
getTextRegionWithLineInformation
org.eclipse.xtext.util.ITextRegionWithLineInformation getTextRegionWithLineInformation()
Returns a
region with line informationfor this node excluding hidden tokens:- an
offsetof this region is the same as anoffsetof this node; - a
lengthof this region is the same as alengthof this node; - a
line numberof this region is the same as astart lineof this node; - an
end line numberof this region is the same as anend lineof this node.
A
line numberand anend line numberof the returned region are one based.This method could be more efficient than calculating an
offset, alength, astart lineand anend lineof this node separately.- Returns:
- a
region with line informationfor this node excluding hidden tokens - Since:
- 2.5
- an
-
getTotalTextRegionWithLineInformation
org.eclipse.xtext.util.ITextRegionWithLineInformation getTotalTextRegionWithLineInformation()
Returns a
region with line informationfor this node including hidden tokens:- an
offsetof this region is the same as atotal offsetof this node; - a
lengthof this region is the same as atotal lengthof this node; - a
line numberof this region is the same as atotal start lineof this node; - an
end line numberof this region is the same as atotal end lineof this node.
A
line numberand anend line numberof the returned region are one based.This method could be more efficient than calculating a
total offset, atotal length, atotal start lineand atotal end lineof this node separately.- Returns:
- a
region with line informationfor this node including hidden tokens - Since:
- 2.5
- an
-
-