Created
July 14, 2022 06:26
-
-
Save xuwei-k/cf77236973dac396a54feb47432abf9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fix | |
import scalafix.Patch | |
import scalafix.v1.SyntacticDocument | |
import scalafix.v1.SyntacticRule | |
import scala.meta.Term | |
class MapSequenceTraverse extends SyntacticRule("MapSequenceTraverse") { | |
override def fix(implicit doc: SyntacticDocument): Patch = { | |
doc.tree.collect { | |
case t @ Term.Select( | |
Term.Apply( | |
Term.Select( | |
qual, | |
Term.Name("map") | |
), | |
arg :: Nil | |
), | |
Term.Name("sequence") | |
) => | |
Patch.replaceTree(t, s"${qual}.traverse(${arg})") | |
} | |
}.asPatch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment