A context dependent, directional movement that can be applied to a SourceWithMarker
Overview
Movements can be combined similar to parser combinators and optionally applied backwards.
They are meant to be used to perform minor tweaks in already parsed source code that might be necessary
due to compiler bugs or compiler API limitations.
Why not use parser combinators?
We want to conveniently move forward and backward in the source code
The code we are looking at is already parsed; we only want to move to specific points
Examples
scala> import scala.tools.refactoring.util.SourceWithMarker
scala> import scala.tools.refactoring.util.SourceWithMarker._
scala> import scala.tools.refactoring.util.SourceWithMarker.Movements._
scala> val src = SourceWithMarker("private val /*---*/ x = 4".toCharArray)
src: scala.tools.refactoring.util.SourceWithMarker =
riv...
scala> val movement = ("private" | "protected") ~ commentsAndSpaces ~ "val" ~ commentsAndSpaces
scala> val srcAtx = src.moveMarker(movement)
srcAtx: scala.tools.refactoring.util.SourceWithMarker = ... <x> = ...
scala> val moveBackToVal = ("al" ~ commentsAndSpaces ~ "x").backward
scala> val srcAtVal = srcAtx.moveMarker(moveBackToVal)
srcAtVal: scala.tools.refactoring.util.SourceWithMarker = ...te <v>al ...
A context dependent, directional movement that can be applied to a SourceWithMarker
Overview
Movements can be combined similar to parser combinators and optionally applied backwards. They are meant to be used to perform minor tweaks in already parsed source code that might be necessary due to compiler bugs or compiler API limitations.
Why not use parser combinators?
Examples
Movements