scala.util.parsing.input
trait Position

[source: `scala/util/parsing/input/Position.scala`]

`` `trait` Position
  `extends` AnyRef

  `Position` is the base class for objects describing a position in a ``document''.

  It provides functionality for:

  - generating a visual representation of this position (`longString');
  - comparing two positions (`<').

  To use this class for a concrete kind of ``document'', implement the `lineContents` method.

Author
  Martin Odersky, Adriaan Moors

Direct Known Subclasses:
  CharArrayPosition, NoPosition

Method Summary
`def` | < (that : Position) : Boolean Compare this position to another, by first comparing their line numbers, and then -- if necessary -- using the columns to break a tie.
`abstract def` | column : Int The column number referred to by the position; column numbers start at 1
`abstract def` | line : Int The line number referred to by the position; line numbers start at 1
`protected abstract def` | lineContents (lnum : Int) : java.lang.String The contents of the line numbered `lnum' (must not contain a new-line character).
`def` | longString : java.lang.String Returns a more ``visual'' representation of this position. More precisely, the resulting string consists of two lines: the line in the document referred to by this position a caret indicating the column Example:
        List(this, is, a, line, from, the, document)
                        ^
`override def` | toString : java.lang.String Returns a string representation of the `Position', of the form `line.column'

Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized

Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf

Method Details

`abstract` `def` line : Int

  The line number referred to by the position; line numbers start at 1

`abstract` `def` column : Int

  The column number referred to by the position; column numbers start at 1

`protected abstract` `def` lineContents(lnum : Int) : java.lang.String

  The contents of the line numbered `lnum' (must not contain a new-line character).

Parameters
  `lnum -` a 1-based integer index into the `document'
Returns
  the line at `lnum' (not including a newline)

`override` `def` toString : java.lang.String

  Returns a string representation of the `Position', of the form `line.column'

`` `def` longString : java.lang.String

  Returns a more ``visual'' representation of this position. More precisely, the resulting string consists of two lines:
  1. the line in the document referred to by this position
  2. a caret indicating the column
  Example:

          List(this, is, a, line, from, the, document)
                          ^

`` `def` <(that : Position) : Boolean

  Compare this position to another, by first comparing their line numbers, and then -- if necessary -- using the columns to break a tie.

Parameters
  ``that' -` a `Position' to compare to this `Position'
Returns
  true if this position's line or (in case of a tie wrt. line numbers) its column is smaller than the corresponding components of `that'