Skip to content

Commit 2da8076

Browse files
bump scalafix to 0.6.0-M8
1 parent 6dd4505 commit 2da8076

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

scalafix/build.sbt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
def scalafixVersion = _root_.scalafix.Versions.version
2-
inScope(Global)(
2+
3+
inThisBuild(
34
List(
4-
scalaVersion := _root_.scalafix.Versions.scala212
5+
scalaVersion := _root_.scalafix.Versions.scala212,
6+
addCompilerPlugin(scalafixSemanticdb),
7+
scalacOptions += "-Yrangepos"
58
)
69
)
710

@@ -17,7 +20,10 @@ lazy val rules = project.settings(
1720

1821
lazy val input = project
1922
.settings(
20-
scalafixSourceroot := sourceDirectory.in(Compile).value
23+
scalacOptions += {
24+
val sourceroot = sourceDirectory.in(Compile).value / "scala"
25+
s"-P:semanticdb:sourceroot:$sourceroot"
26+
}
2127
)
2228

2329
lazy val output = project
@@ -29,16 +35,12 @@ lazy val output = project
2935
lazy val tests = project
3036
.settings(
3137
libraryDependencies += "ch.epfl.scala" % "scalafix-testkit" % scalafixVersion % Test cross CrossVersion.full,
32-
buildInfoPackage := "fix",
33-
buildInfoKeys := Seq[BuildInfoKey](
34-
"inputSourceroot" ->
35-
sourceDirectory.in(input, Compile).value,
36-
"outputSourceroot" ->
37-
sourceDirectory.in(output, Compile).value,
38-
"inputClassdirectory" ->
39-
classDirectory.in(input, Compile).value
40-
),
41-
test in Test := (test in Test).dependsOn(compile in (output, Compile)).value
38+
scalafixTestkitOutputSourceDirectories :=
39+
sourceDirectories.in(output, Compile).value,
40+
scalafixTestkitInputSourceDirectories :=
41+
sourceDirectories.in(input, Compile).value,
42+
scalafixTestkitInputClasspath :=
43+
fullClasspath.in(input, Compile).value
4244
)
4345
.dependsOn(input, rules)
44-
.enablePlugins(BuildInfoPlugin)
46+
.enablePlugins(ScalafixTestkitPlugin)

scalafix/project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.10")
1+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.6.0-M8")
22
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0")
33
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.6.1")

scalafix/rules/src/main/scala/fix/Scalacollectioncompat_NewCollections.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ case class Scalacollectioncompat_NewCollections(index: SemanticdbIndex)
4949
Symbol("_root_.scala.collection.mutable.SetLike.retain.")
5050
)
5151

52-
def replaceMutableSet(ctx: RuleCtx) =
52+
def replaceMutableSet(ctx: RuleCtx): Patch =
5353
ctx.tree.collect {
5454
case retainSet(n: Name) =>
5555
ctx.replaceTree(n, "filterInPlace")
5656
}.asPatch
5757

58-
def replaceMutableMap(ctx: RuleCtx) =
58+
def replaceMutableMap(ctx: RuleCtx): Patch =
5959
ctx.tree.collect {
6060
case Term.Apply(Term.Select(_, retainMap(n: Name)), List(_: Term.PartialFunction)) =>
6161
ctx.replaceTree(n, "filterInPlace")
@@ -72,7 +72,7 @@ case class Scalacollectioncompat_NewCollections(index: SemanticdbIndex)
7272
).asPatch
7373
}.asPatch
7474

75-
def replaceSymbolicFold(ctx: RuleCtx) =
75+
def replaceSymbolicFold(ctx: RuleCtx): Patch =
7676
ctx.tree.collect {
7777
case Term.Apply(ap @ Term.ApplyInfix(rhs, foldRightSymbol(_), _, List(lhs)), _) =>
7878
ctx.replaceTree(ap, s"$rhs.foldRight($lhs)")
@@ -81,7 +81,7 @@ case class Scalacollectioncompat_NewCollections(index: SemanticdbIndex)
8181
ctx.replaceTree(ap, s"$rhs.foldLeft($lhs)")
8282
}.asPatch
8383

84-
def replaceToList(ctx: RuleCtx) =
84+
def replaceToList(ctx: RuleCtx): Patch =
8585
ctx.tree.collect {
8686
case iterator(t: Name) =>
8787
ctx.replaceTree(t, "iterator")
@@ -96,7 +96,7 @@ case class Scalacollectioncompat_NewCollections(index: SemanticdbIndex)
9696
).asPatch
9797
}.asPatch
9898

99-
def replaceTupleZipped(ctx: RuleCtx) =
99+
def replaceTupleZipped(ctx: RuleCtx): Patch =
100100
ctx.tree.collect {
101101
case tupleZipped(Term.Select(Term.Tuple(args), name)) =>
102102
val removeTokensPatch =
@@ -157,8 +157,6 @@ case class Scalacollectioncompat_NewCollections(index: SemanticdbIndex)
157157
}.asPatch
158158

159159
override def fix(ctx: RuleCtx): Patch = {
160-
// println(ctx.index.database)
161-
162160
replaceToList(ctx) +
163161
replaceSymbols(ctx) +
164162
replaceTupleZipped(ctx) +
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
package fix
22

33
import scala.meta._
4-
import scalafix.testkit._
54
import scalafix._
5+
import scalafix.v0._
66

7-
class Collectionstrawman_Tests
8-
extends SemanticRuleSuite(
9-
SemanticdbIndex.load(Classpath(AbsolutePath(BuildInfo.inputClassdirectory))),
10-
AbsolutePath(BuildInfo.inputSourceroot),
11-
Seq(AbsolutePath(BuildInfo.outputSourceroot))
12-
) {
7+
class Scalafixplayground_Tests
8+
extends scalafix.testkit.SemanticRuleSuite {
139
runAllTests()
1410
}

0 commit comments

Comments
 (0)