A context dependent, directional movement that can be applied to a SourceWithMarker
A context dependent, directional movement that can be applied to a SourceWithMarker
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.
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 Movement that can be applied in one direction.
A Movement that can be applied in one direction.
The difference between a SimpleMovement and a Movement is that SimpleMovement
is missing the backward
method. Apart from that, the documentation for Movement applies.
Note that movements can be combined with simple movements, so there is no need to
implement a full movement unless you need it.
Various movements related to Scala code
Various movements related to Scala code
Take a look at the Scala Language Specification if you wonder about terms like plainid, idrest or varid.