Class Pos


  • public class Pos
    extends Object
    Position of a parse-tree node.
    • Field Detail

      • ZERO

        public static final Pos ZERO
      • file

        public final String file
      • startLine

        public final int startLine
      • startColumn

        public final int startColumn
      • endLine

        public final int endLine
      • endColumn

        public final int endColumn
    • Constructor Detail

      • Pos

        public Pos​(String file,
                   int startLine,
                   int startColumn,
                   int endLine,
                   int endColumn)
        Creates a Pos.
    • Method Detail

      • of

        public static Pos of​(String ml,
                             String file,
                             int startOffset,
                             int endOffset)
        Creates a Pos from two offsets.
      • split

        public static org.apache.calcite.util.Pair<@NonNull String,​@NonNull Pos> split​(String s,
                                                                                             char delimiter,
                                                                                             String file)
        Creates a Pos from a filename and a string with a delimiter character. The delimiter must occur exactly twice in the string.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • sum

        public static Pos sum​(Iterable<Pos> poses)
        Combines an iterable of parser positions to create a position which spans from the beginning of the first to the end of the last.
      • sum_

        private static Pos sum_​(List<Pos> positions)
        Combines a list of parser positions to create a position which spans from the beginning of the first to the end of the last.
      • sum

        private static Pos sum​(Iterable<Pos> poses,
                               int line,
                               int column,
                               int endLine,
                               int endColumn)
        Computes the parser position which is the sum of an array of parser positions and of a parser position represented by (line, column, endLine, endColumn).
        Parameters:
        poses - Array of parser positions
        line - Start line
        column - Start column
        endLine - End line
        endColumn - End column
        Returns:
        Sum of parser positions
      • plus

        public Pos plus​(Pos pos)
      • lineCol

        private static org.apache.calcite.util.mapping.IntPair lineCol​(String s,
                                                                       int offset)
        Returns the 1-based line.