Skip to content

bump scalafix to 0.6.0-M8 #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions scalafix/build.sbt
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
def scalafixVersion = _root_.scalafix.Versions.version
inScope(Global)(
List(
scalaVersion := _root_.scalafix.Versions.scala212
)

lazy val baseSettings = Seq(
scalaVersion := _root_.scalafix.Versions.scala212
)

lazy val root = project
.in(file("."))
.aggregate(
rules, input, output, tests
)
.settings(baseSettings)
.aggregate(rules, input, output, tests)

lazy val rules = project.settings(
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % scalafixVersion
)
lazy val rules = project
.settings(baseSettings)
.settings(
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % scalafixVersion
)

lazy val input = project
.settings(baseSettings)
.settings(
scalafixSourceroot := sourceDirectory.in(Compile).value
addCompilerPlugin(scalafixSemanticdb),
scalacOptions ++= {
val sourceroot = sourceDirectory.in(Compile).value / "scala"
Seq(
"-Yrangepos",
s"-P:semanticdb:sourceroot:$sourceroot"
)
}
)

lazy val output = project
Expand All @@ -27,18 +35,15 @@ lazy val output = project
)

lazy val tests = project
.settings(baseSettings)
.settings(
libraryDependencies += "ch.epfl.scala" % "scalafix-testkit" % scalafixVersion % Test cross CrossVersion.full,
buildInfoPackage := "fix",
buildInfoKeys := Seq[BuildInfoKey](
"inputSourceroot" ->
sourceDirectory.in(input, Compile).value,
"outputSourceroot" ->
sourceDirectory.in(output, Compile).value,
"inputClassdirectory" ->
classDirectory.in(input, Compile).value
),
test in Test := (test in Test).dependsOn(compile in (output, Compile)).value
scalafixTestkitOutputSourceDirectories :=
sourceDirectories.in(output, Compile).value,
scalafixTestkitInputSourceDirectories :=
sourceDirectories.in(input, Compile).value,
scalafixTestkitInputClasspath :=
fullClasspath.in(input, Compile).value
)
.dependsOn(input, rules)
.enablePlugins(BuildInfoPlugin)
.enablePlugins(ScalafixTestkitPlugin)
2 changes: 1 addition & 1 deletion scalafix/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.10")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.6.0-M8")
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.6.1")
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ case class Scalacollectioncompat_newcollections(index: SemanticdbIndex)
Symbol("_root_.scala.collection.mutable.SetLike.retain.")
)

def replaceMutableSet(ctx: RuleCtx) =
def replaceMutableSet(ctx: RuleCtx): Patch =
ctx.tree.collect {
case retainSet(n: Name) =>
ctx.replaceTree(n, "filterInPlace")
}.asPatch

def replaceMutableMap(ctx: RuleCtx) =
def replaceMutableMap(ctx: RuleCtx): Patch =
ctx.tree.collect {
case Term.Apply(Term.Select(_, retainMap(n: Name)), List(_: Term.PartialFunction)) =>
ctx.replaceTree(n, "filterInPlace")
Expand All @@ -72,7 +72,7 @@ case class Scalacollectioncompat_newcollections(index: SemanticdbIndex)
).asPatch
}.asPatch

def replaceSymbolicFold(ctx: RuleCtx) =
def replaceSymbolicFold(ctx: RuleCtx): Patch =
ctx.tree.collect {
case Term.Apply(ap @ Term.ApplyInfix(rhs, foldRightSymbol(_), _, List(lhs)), _) =>
ctx.replaceTree(ap, s"$rhs.foldRight($lhs)")
Expand All @@ -81,7 +81,7 @@ case class Scalacollectioncompat_newcollections(index: SemanticdbIndex)
ctx.replaceTree(ap, s"$rhs.foldLeft($lhs)")
}.asPatch

def replaceToList(ctx: RuleCtx) =
def replaceToList(ctx: RuleCtx): Patch =
ctx.tree.collect {
case iterator(t: Name) =>
ctx.replaceTree(t, "iterator")
Expand All @@ -96,7 +96,7 @@ case class Scalacollectioncompat_newcollections(index: SemanticdbIndex)
).asPatch
}.asPatch

def replaceTupleZipped(ctx: RuleCtx) =
def replaceTupleZipped(ctx: RuleCtx): Patch =
ctx.tree.collect {
case tupleZipped(Term.Select(Term.Tuple(args), name)) =>
val removeTokensPatch =
Expand Down Expand Up @@ -157,8 +157,6 @@ case class Scalacollectioncompat_newcollections(index: SemanticdbIndex)
}.asPatch

override def fix(ctx: RuleCtx): Patch = {
// println(ctx.index.database)

replaceToList(ctx) +
replaceSymbols(ctx) +
replaceTupleZipped(ctx) +
Expand Down
10 changes: 3 additions & 7 deletions scalafix/tests/src/test/scala/fix/Collectionstrawman_Tests.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package fix

import scala.meta._
import scalafix.testkit._
import scalafix._
import scalafix.v0._

class Collectionstrawman_Tests
extends SemanticRuleSuite(
SemanticdbIndex.load(Classpath(AbsolutePath(BuildInfo.inputClassdirectory))),
AbsolutePath(BuildInfo.inputSourceroot),
Seq(AbsolutePath(BuildInfo.outputSourceroot))
) {
class Scalafixplayground_Tests
extends scalafix.testkit.SemanticRuleSuite {
runAllTests()
}