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

scala.meta.internal.parsers.Absolutize.scala Maven / Gradle / Ivy

There is a newer version: 4.12.2
Show newest version
package scala.meta
package internal
package parsers

import scala.meta.inputs._
import scala.meta.parsers._
import scala.meta.tokenizers._

object Absolutize {
  implicit class XtensionPositionAbsolutize(pos: Position) {
    def absolutize: Position = {
      pos match {
        case Position.Range(Input.Slice(input, absoluteStart, _), start, end) =>
          val start1 = absoluteStart + start
          val end1 = absoluteStart + end
          Position.Range(input, start1, end1)
        case other =>
          other
      }
    }
  }

  implicit class XtensionExceptionAbsolutize(ex: Throwable) {
    def absolutize: Throwable = {
      val ex1 = ex match {
        case TokenizeException(pos, message) =>
          TokenizeException(pos.absolutize, message)
        case ParseException(pos, message) =>
          ParseException(pos.absolutize, message)
        case PlatformInvocationTargetException(ex) => ex
      }
      ex1.setStackTrace(ex.getStackTrace)
      ex1
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy