Class InternalNodeModelUtils

  • Direct Known Subclasses:
    NodeModelUtils

    public class InternalNodeModelUtils
    extends java.lang.Object
    Internal base class for node model utilities with access to implementation details of the node model. It is intentional that the methods here are available to clients only with some effort because they rely on internal semantics of the node model implementation.
    Since:
    2.9
    Noreference:
    This class is not intended to be referenced by clients.
    Noextend:
    This class is not intended to be subclassed by clients.
    Noinstantiate:
    This class is not intended to be instantiated by clients.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static AbstractNode basicGetFirstChild​(CompositeNode node)
      Obtain the first child node of the given node.
      protected static AbstractNode basicGetLastChild​(CompositeNode node)
      Obtain the last child node of the given node.
      protected static CompositeNode basicGetParent​(AbstractNode node)
      Obtain the parent node of the given node.
      protected static int[] computeLineBreaks​(java.lang.String text)
      Computes the line breaks in the given text and returns an array of offsets.
      protected static org.eclipse.xtext.util.LineAndColumn getLineAndColumn​(java.lang.String text, int[] lineBreaks, int offset)  
      protected static org.eclipse.xtext.util.LineAndColumn getLineAndColumn​(INode anyNode, int documentOffset)
      Obtain the line breaks from the document and search / compute the line number and column number at the given document offset.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InternalNodeModelUtils

        protected InternalNodeModelUtils()
    • Method Detail

      • getLineAndColumn

        protected static org.eclipse.xtext.util.LineAndColumn getLineAndColumn​(INode anyNode,
                                                                               int documentOffset)
        Obtain the line breaks from the document and search / compute the line number and column number at the given document offset.
      • basicGetParent

        protected static CompositeNode basicGetParent​(AbstractNode node)
        Obtain the parent node of the given node. Does not unfold synthetic nodes. May return null.
        Since:
        2.24
      • basicGetFirstChild

        protected static AbstractNode basicGetFirstChild​(CompositeNode node)
        Obtain the first child node of the given node. Does not unfold synthetic nodes. May return null.
        Since:
        2.24
      • basicGetLastChild

        protected static AbstractNode basicGetLastChild​(CompositeNode node)
        Obtain the last child node of the given node. Does not unfold synthetic nodes. May return null.
        Since:
        2.24
      • getLineAndColumn

        protected static org.eclipse.xtext.util.LineAndColumn getLineAndColumn​(java.lang.String text,
                                                                               int[] lineBreaks,
                                                                               int offset)
      • computeLineBreaks

        protected static 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. It follows the semantics of LineNumberReader. The offsets in the returned array are the offset of the line break itself. If the line-break contains of two characters ('\r\n'), it's the offset of the first char ('\r').
        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.