org.eclipse.xtext.nodemodel.impl
Class RootNode

java.lang.Object
  extended by org.eclipse.xtext.nodemodel.impl.AbstractNode
      extended by org.eclipse.xtext.nodemodel.impl.CompositeNode
          extended by org.eclipse.xtext.nodemodel.impl.CompositeNodeWithSemanticElement
              extended by org.eclipse.xtext.nodemodel.impl.CompositeNodeWithSemanticElementAndSyntaxError
                  extended by org.eclipse.xtext.nodemodel.impl.RootNode
All Implemented Interfaces:
java.lang.Iterable<INode>, org.eclipse.emf.common.notify.Adapter, BidiIterable<INode>, BidiTreeIterable<INode>, ICompositeNode, INode

public class RootNode
extends CompositeNodeWithSemanticElementAndSyntaxError

Author:
Sebastian Zarnekow - Initial contribution and API
This class is not intended to be subclassed by clients.
This class is not intended to be subclassed by clients.

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
org.eclipse.emf.common.notify.Adapter.Internal
 
Constructor Summary
RootNode()
           
 
Method Summary
protected  int[] basicGetLineBreakOffsets()
          Returns an array that contains the offsets of each line break in the input.
protected  AbstractNode basicGetNextSibling()
           
protected  AbstractNode basicGetPreviousSibling()
           
protected  boolean basicHasNextSibling()
           
protected  boolean basicHasPreviousSibling()
           
protected  void basicSetCompleteContent(java.lang.String completeContent)
           
protected  void basicSetNextSibling(AbstractNode next)
           
protected  void basicSetParent(CompositeNode parent)
           
protected  void basicSetPreviousSibling(AbstractNode prev)
           
protected  int[] computeLineBreaks(java.lang.String text)
          Computes the line breaks in the given text and returns an array of offsets.
 java.lang.String getCompleteContent()
           
 int getIndex()
           
 INode getNextSibling()
          Returns the next sibling or null.
 CompositeNode 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.
 java.lang.String getText()
          Returns the parsed text that is covered by 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.
 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.
 
Methods inherited from class org.eclipse.xtext.nodemodel.impl.CompositeNodeWithSemanticElementAndSyntaxError
basicSetSyntaxErrorMessage, getSyntaxErrorMessage
 
Methods inherited from class org.eclipse.xtext.nodemodel.impl.CompositeNodeWithSemanticElement
basicGetSemanticElement, basicSetSemanticElement, getSemanticElement, getTarget, isAdapterForType, notifyChanged, setTarget
 
Methods inherited from class org.eclipse.xtext.nodemodel.impl.CompositeNode
basicGetChildren, basicGetFirstChild, basicGetLastChild, basicSetFirstChild, basicSetLookAhead, getChildren, getFirstChild, getGrammarElement, getLastChild, getLookAhead, hasChildren, isFolded, isFolded, resolveAsParent
 
Methods inherited from class org.eclipse.xtext.nodemodel.impl.AbstractNode
basicGetGrammarElement, basicGetLineOfOffset, basicGetParent, basicHasSiblings, basicIterator, basicSetGrammarElement, getAsTreeIterable, getEndLine, getLeafNodes, getLength, getOffset, getStartLine, getTotalEndLine, getTotalEndOffset, getTotalStartLine, hasDirectSemanticElement, iterator, reverse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.xtext.nodemodel.INode
getAsTreeIterable, getEndLine, getLeafNodes, getLength, getOffset, getStartLine, getTotalEndLine, getTotalEndOffset, getTotalStartLine, hasDirectSemanticElement
 

Constructor Detail

RootNode

public RootNode()
Method Detail

getParent

public CompositeNode getParent()
Description copied from interface: INode
Returns the parent of the node or null if and only if this is the root node.

Specified by:
getParent in interface INode
Overrides:
getParent in class AbstractNode
Returns:
null the root node does not have any parent.

getRootNode

public ICompositeNode getRootNode()
Description copied from interface: INode
Returns the root node of this parse tree. Will not return null in a consistent tree.

Specified by:
getRootNode in interface INode
Overrides:
getRootNode in class AbstractNode
Returns:
the root node of this parse tree. Will not return null in a consistent tree.

getTotalOffset

public int getTotalOffset()
Description copied from interface: INode
Returns the offset of this node including hidden tokens.

Specified by:
getTotalOffset in interface INode
Overrides:
getTotalOffset in class CompositeNode
Returns:
the offset of this node including hidden tokens.

getTotalLength

public int getTotalLength()
Description copied from interface: INode
Returns the length of this node including hidden tokens.

Specified by:
getTotalLength in interface INode
Overrides:
getTotalLength in class CompositeNode
Returns:
the length of this node including hidden tokens.

getText

public java.lang.String getText()
Description copied from interface: INode
Returns the parsed text that is covered by this node (including hidden tokens). The result is never null but may be empty.

Specified by:
getText in interface INode
Overrides:
getText in class AbstractNode
Returns:
the parsed text that is covered by this node (including hidden tokens). Never null.

getIndex

public int getIndex()

basicSetCompleteContent

protected void basicSetCompleteContent(java.lang.String completeContent)

basicGetLineBreakOffsets

protected int[] basicGetLineBreakOffsets()
Returns an array that contains the offsets of each line break in the input. Note that the result is not a copy but the actually internal data structure of this node.

Returns:
an array of offsets of each line break in the input or null if the completeContent has not been set.
Since:
2.0

getCompleteContent

public java.lang.String getCompleteContent()

getNextSibling

public INode getNextSibling()
Description copied from interface: INode
Returns the next sibling or null. The result has the same parent as this node if it is not null.

Specified by:
getNextSibling in interface INode
Overrides:
getNextSibling in class AbstractNode
Returns:
the next sibling or null.
See Also:
INode.hasNextSibling(), INode.hasSiblings()

getPreviousSibling

public INode getPreviousSibling()
Description copied from interface: INode
Returns the previous sibling or null. The result has the same parent as this node if it is not null.

Specified by:
getPreviousSibling in interface INode
Overrides:
getPreviousSibling in class AbstractNode
Returns:
the previous sibling or null.
See Also:
INode.hasPreviousSibling(), INode.hasSiblings()

basicGetNextSibling

protected AbstractNode basicGetNextSibling()
Overrides:
basicGetNextSibling in class AbstractNode

basicGetPreviousSibling

protected AbstractNode basicGetPreviousSibling()
Overrides:
basicGetPreviousSibling in class AbstractNode

basicHasPreviousSibling

protected boolean basicHasPreviousSibling()
Overrides:
basicHasPreviousSibling in class AbstractNode

basicHasNextSibling

protected boolean basicHasNextSibling()
Overrides:
basicHasNextSibling in class AbstractNode

hasPreviousSibling

public boolean hasPreviousSibling()
Description copied from interface: INode
Returns true if this node is not the first child of its parent.

Specified by:
hasPreviousSibling in interface INode
Overrides:
hasPreviousSibling in class AbstractNode

hasNextSibling

public boolean hasNextSibling()
Description copied from interface: INode
Returns true if this node is not the last child of its parent.

Specified by:
hasNextSibling in interface INode
Overrides:
hasNextSibling in class AbstractNode

hasSiblings

public boolean hasSiblings()
Description copied from interface: INode
Returns true if this node has any siblings.

Specified by:
hasSiblings in interface INode
Overrides:
hasSiblings in class AbstractNode
Returns:
true if this node has any siblings.
See Also:
INode.hasPreviousSibling(), INode.hasNextSibling()

basicSetNextSibling

protected void basicSetNextSibling(AbstractNode next)
Overrides:
basicSetNextSibling in class AbstractNode

basicSetPreviousSibling

protected void basicSetPreviousSibling(AbstractNode prev)
Overrides:
basicSetPreviousSibling in class AbstractNode

basicSetParent

protected void basicSetParent(CompositeNode parent)
Overrides:
basicSetParent in class AbstractNode

computeLineBreaks

protected int[] computeLineBreaks(java.lang.String text)

Computes the line breaks in the given text and returns an array of offsets. A line break is either \r\n, \n, or a single \r.

This implementation was heavily adapted from org.eclipse.jface.text.DefaultLineTracker.

Parameters:
text - the text whose line-breaks should be computed. May not be null.
Returns:
the array of line-break offsets in the given text. May be empty but is never null.
Since:
2.0
See Also:
DefaultLineTracker