public abstract class AbstractNode extends java.lang.Object implements INode, BidiTreeIterable<INode>
Constructor and Description |
---|
AbstractNode() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
basicGetGrammarElement() |
protected int |
basicGetLineOfOffset(INode rootNode,
int offset) |
protected AbstractNode |
basicGetNextSibling() |
protected CompositeNode |
basicGetParent() |
protected AbstractNode |
basicGetPreviousSibling() |
protected org.eclipse.emf.ecore.EObject |
basicGetSemanticElement() |
protected boolean |
basicHasNextSibling() |
protected boolean |
basicHasPreviousSibling() |
protected boolean |
basicHasSiblings() |
BidiTreeIterator<AbstractNode> |
basicIterator() |
protected void |
basicSetGrammarElement(java.lang.Object grammarElementOrArray) |
protected void |
basicSetNextSibling(AbstractNode next) |
protected void |
basicSetParent(CompositeNode parent) |
protected void |
basicSetPreviousSibling(AbstractNode prev) |
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).
|
int |
getEndOffset()
Returns the end offset (exclusive) of this node 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).
|
ITextRegion |
getTextRegion()
|
ITextRegionWithLineInformation |
getTextRegionWithLineInformation()
Returns a
region with line information for this node excluding hidden tokens:
an offset of this region is the same as an offset of this node;
a length of this region is the same as a length of this node;
a line number of this region is the same as a start line of this node;
an end line number of this region is the same as an end line of this node. |
protected ITextRegionWithLineInformation |
getTextRegionWithLineInformation(int offset,
int length) |
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 |
getTotalStartLine()
Returns the line number relative to the complete input where the node begins
(one based, including hidden tokens).
|
ITextRegion |
getTotalTextRegion()
Returns a
region for this node including hidden tokens:
an offset of this region is the same as a total offset of this node;
and a length of this region is the same as a total length of this node. |
ITextRegionWithLineInformation |
getTotalTextRegionWithLineInformation()
Returns a
region with line information for this node including hidden tokens:
an offset of this region is the same as a total offset of this node;
a length of this region is the same as a total length of this node;
a line number of this region is the same as a total start line of this node;
an end line number of this region is the same as a total end line of this node. |
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. |
BidiTreeIterator<INode> |
iterator()
Returns a tree iterator that can be used forwards and backwards.
|
BidiTreeIterable<INode> |
reverse()
Returns a reverse version of this iterable that can be used
forwards and backwards.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getTotalLength, getTotalOffset
public ITextRegion getTextRegion()
INode
Returns a region
for this node excluding hidden tokens:
offset
of this region is the same as an offset
of this node;length
of this region is the same as a length
of this node.
This method could be more efficient than calculating an offset
and a length
of this node separately.
getTextRegion
in interface INode
region
for this node excluding hidden tokenspublic ITextRegion getTotalTextRegion()
INode
Returns a region
for this node including hidden tokens:
offset
of this region is the same as a total offset
of this node;length
of this region is the same as a total length
of this node.
This method could be more efficient than calculating a total offset
and a total length
of this node separately.
getTotalTextRegion
in interface INode
region
for this node including hidden tokenspublic ITextRegionWithLineInformation getTextRegionWithLineInformation()
INode
Returns a region with line information
for this node excluding hidden tokens:
offset
of this region is the same as an offset
of this node;length
of this region is the same as a length
of this node;line number
of this region is the same as a start line
of this node;end line number
of this region is the same as an end line
of this node.
A line number
and
an end line number
of the returned region are one based.
This method could be more efficient than calculating an offset
, a length
,
a start line
and an end line
of this node separately.
getTextRegionWithLineInformation
in interface INode
region with line information
for this node excluding hidden tokenspublic ITextRegionWithLineInformation getTotalTextRegionWithLineInformation()
INode
Returns a region with line information
for this node including hidden tokens:
offset
of this region is the same as a total offset
of this node;length
of this region is the same as a total length
of this node;line number
of this region is the same as a total start line
of this node;end line number
of this region is the same as a total end line
of this node.
A line number
and
an end line number
of the returned region are one based.
This method could be more efficient than calculating a total offset
, a total length
,
a total start line
and a total end line
of this node separately.
getTotalTextRegionWithLineInformation
in interface INode
region with line information
for this node including hidden tokensprotected ITextRegionWithLineInformation getTextRegionWithLineInformation(int offset, int length)
public ICompositeNode getParent()
INode
null
if and only if this is the root node.protected CompositeNode basicGetParent()
protected void basicSetParent(CompositeNode parent)
public BidiTreeIterable<INode> getAsTreeIterable()
INode
BidiTreeIterator.previous()
or BidiTreeIterator.next()
will be this instance.getAsTreeIterable
in interface INode
public BidiTreeIterator<INode> iterator()
BidiTreeIterable
iterator
in interface java.lang.Iterable<INode>
iterator
in interface BidiIterable<INode>
iterator
in interface BidiTreeIterable<INode>
null
.public BidiTreeIterable<INode> reverse()
BidiTreeIterable
Returns a reverse version of this iterable that can be used
forwards and backwards. In other words, an iterator provided by
the reverse iterable will delegate its hasNext()
and next()
invocations to
BidiIterator.hasPrevious()
and BidiIterator.previous()
respectively.
This allows clients to iterate backwards by means of the enhanced for-loop:
for(T t: iterable.reverse()) { // do something with t }
reverse
in interface BidiIterable<INode>
reverse
in interface BidiTreeIterable<INode>
null
.public java.lang.Iterable<ILeafNode> getLeafNodes()
INode
null
.getLeafNodes
in interface INode
null
.public BidiTreeIterator<AbstractNode> basicIterator()
public java.lang.String getText()
INode
null
but may be empty.public int getTotalStartLine()
INode
getTotalStartLine
in interface INode
protected int basicGetLineOfOffset(INode rootNode, int offset)
public int getStartLine()
INode
getStartLine
in interface INode
public int getEndLine()
INode
getEndLine
in interface INode
public int getTotalEndLine()
INode
getTotalEndLine
in interface INode
public int getOffset()
INode
public int getLength()
INode
public int getTotalEndOffset()
INode
offset
+
length
but may be more efficient.getTotalEndOffset
in interface INode
public int getEndOffset()
INode
offset
+
length
but may be more efficient.getEndOffset
in interface INode
public ICompositeNode getRootNode()
INode
null
in a consistent tree.getRootNode
in interface INode
null
in a consistent tree.public org.eclipse.emf.ecore.EObject getSemanticElement()
INode
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.getSemanticElement
in interface INode
null
.INode.hasDirectSemanticElement()
,
NodeModelUtils.findActualSemanticObjectFor(INode)
protected org.eclipse.emf.ecore.EObject basicGetSemanticElement()
public boolean hasDirectSemanticElement()
INode
true
if this node as a directly associated semantic element.hasDirectSemanticElement
in interface INode
true
if this node as a directly associated semantic element.INode.getSemanticElement()
public org.eclipse.emf.ecore.EObject getGrammarElement()
INode
null
in case of unrecoverable syntax
errors. This happens usually when a keyword occurred at an unexpected offset.getGrammarElement
in interface INode
null
.protected java.lang.Object basicGetGrammarElement()
protected void basicSetGrammarElement(java.lang.Object grammarElementOrArray)
public SyntaxErrorMessage getSyntaxErrorMessage()
INode
null
if none.getSyntaxErrorMessage
in interface INode
null
.public INode getPreviousSibling()
INode
null
. The result has the same parent
as this node if it is not null
.getPreviousSibling
in interface INode
null
.INode.hasPreviousSibling()
,
INode.hasSiblings()
protected AbstractNode basicGetPreviousSibling()
protected void basicSetPreviousSibling(AbstractNode prev)
public INode getNextSibling()
INode
getNextSibling
in interface INode
null
.INode.hasNextSibling()
,
INode.hasSiblings()
protected AbstractNode basicGetNextSibling()
protected void basicSetNextSibling(AbstractNode next)
public boolean hasPreviousSibling()
INode
true
if this node is not the first child of its parent.hasPreviousSibling
in interface INode
true
if this node has a previous sibling thus INode.getPreviousSibling()
will
not return null
.protected boolean basicHasPreviousSibling()
public boolean hasNextSibling()
INode
true
if this node is not the last child of its parent.hasNextSibling
in interface INode
true
if this node has a next sibling thus INode.getNextSibling()
will
not return null
.protected boolean basicHasNextSibling()
public boolean hasSiblings()
INode
true
if this node has any siblings.hasSiblings
in interface INode
true
if this node has any siblings.INode.hasPreviousSibling()
,
INode.hasNextSibling()
protected boolean basicHasSiblings()