
sangria.parser.PositionTracking.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sangria_2.11 Show documentation
Show all versions of sangria_2.11 Show documentation
Scala GraphQL implementation
package sangria.parser
import org.parboiled2._
trait PositionTracking { this: Parser ⇒
private var lineIdx = Vector(0)
def trackNewLine: Rule0 = rule { run(if (!(lineIdx contains cursor)) lineIdx = lineIdx :+ cursor) }
def trackPos = rule {
push {
val currLines = lineIdx.takeWhile(_ <= cursor)
Position(cursor, currLines.size, cursor - currLines.last + 1)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy