All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.virtuslab.yaml.Range.scala Maven / Gradle / Ivy

There is a newer version: 0.3.0
Show newest version
package org.virtuslab.yaml

final case class Position(
    offset: Int,
    line: Int,
    column: Int
)

final case class Range(
    start: Position,
    input: Vector[String],
    end: Option[Position] = None
) {
  def errorMsg: String = {
    val msg    = input(start.line)
    val spaces = start.column
    s"""|$msg
        |${" " * spaces}^""".stripMargin
  }

  def withEndPos(end: Position): Range =
    copy(
      end = Some(end)
    )

  def show: String = s"Position(${start.line}, ${start.column}), offset ${start.offset}"
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy