LocationMap

cats.parse.LocationMap
See theLocationMap companion object
class LocationMap(val input: String)

This is a class to convert linear offset in a string into lines, or the column and line numbers.

This is useful for display to humans who in text editors think in terms of line and column numbers

Attributes

Companion
object
Source
LocationMap.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def getLine(i: Int): Option[String]

return the line without a newline

return the line without a newline

Attributes

Source
LocationMap.scala
def isValidOffset(offset: Int): Boolean

Attributes

Source
LocationMap.scala
def lineCount: Int

How many lines are there

How many lines are there

Attributes

Source
LocationMap.scala
def toCaret(offset: Int): Option[Caret]

Attributes

Source
LocationMap.scala
def toCaretUnsafe(offset: Int): Caret

Convert an offset to a Caret. throws IllegalArgumentException if offset is longer than input

Convert an offset to a Caret. throws IllegalArgumentException if offset is longer than input

Attributes

Source
LocationMap.scala
def toLineCol(offset: Int): Option[(Int, Int)]

Given a string offset return the line and column If input.length is given (EOF) we return the same value as if the string were one character longer (i.e. if we have appended a non-newline character at the EOF)

Given a string offset return the line and column If input.length is given (EOF) we return the same value as if the string were one character longer (i.e. if we have appended a non-newline character at the EOF)

Attributes

Source
LocationMap.scala
def toOffset(line: Int, col: Int): Option[Int]

Return the offset for a given line/col. if we return Some(input.length) this means EOF if we return Some(i) for 0 <= i < input.length it is a valid item else offset < 0 or offset > input.length we return None

Return the offset for a given line/col. if we return Some(input.length) this means EOF if we return Some(i) for 0 <= i < input.length it is a valid item else offset < 0 or offset > input.length we return None

Attributes

Source
LocationMap.scala

Concrete fields

val input: String

Attributes

Source
LocationMap.scala