-
-
Save joyoyoyoyoyo/27107f0580f407fd0047b7457e18e7d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sbt | |
package internal | |
package fix | |
import scalafix.v1._ | |
import scala.meta._ | |
class Sbt0_13BuildSyntax extends SyntacticRule("Sbt0_13BuildSyntax") { | |
override def fix(implicit doc: SyntacticDocument): Patch = { | |
doc.tree.collect { | |
case t: Term.ApplyInfix if t.op.value == "in" && t.lhs.toString != "project" => | |
slashify(t, t.lhs, t.args) | |
case t @ Term.Apply(Term.Select(qual, Term.Name("in")), args) if qual.toString != "project" => | |
slashify(t, qual, args) | |
}.asPatch | |
} | |
def slashify(t: Tree, lhs: Term, args: Seq[Term]): Patch = | |
args match { | |
case List(arg0) => | |
Patch.replaceTree(t, s"($arg0 / $lhs)") | |
case List(arg0, arg1) => | |
Patch.replaceTree(t, s"($arg0 / $arg1 / $lhs)") | |
case List(arg0, arg1, arg2) => | |
Patch.replaceTree(t, s"($arg0 / $arg1 / $arg2 / $lhs)") | |
case _ => Patch.empty | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment