Skip to content

Commit db5b7cb

Browse files
bump scalafix to 0.6.0-M8
1 parent 3688ecf commit db5b7cb

File tree

4 files changed

+36
-37
lines changed

4 files changed

+36
-37
lines changed

scalafix/build.sbt

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
def scalafixVersion = _root_.scalafix.Versions.version
2-
inScope(Global)(
3-
List(
4-
scalaVersion := _root_.scalafix.Versions.scala212
5-
)
2+
3+
lazy val baseSettings = Seq(
4+
scalaVersion := _root_.scalafix.Versions.scala212
65
)
76

87
lazy val root = project
98
.in(file("."))
10-
.aggregate(
11-
rules, input, output, tests
12-
)
9+
.settings(baseSettings)
10+
.aggregate(rules, input, output, tests)
1311

14-
lazy val rules = project.settings(
15-
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % scalafixVersion
16-
)
12+
lazy val rules = project
13+
.settings(baseSettings)
14+
.settings(
15+
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % scalafixVersion
16+
)
1717

1818
lazy val input = project
19+
.settings(baseSettings)
1920
.settings(
20-
scalafixSourceroot := sourceDirectory.in(Compile).value
21+
addCompilerPlugin(scalafixSemanticdb),
22+
scalacOptions ++= {
23+
val sourceroot = sourceDirectory.in(Compile).value / "scala"
24+
Seq(
25+
"-Yrangepos",
26+
s"-P:semanticdb:sourceroot:$sourceroot"
27+
)
28+
}
2129
)
2230

2331
lazy val output = project
@@ -27,18 +35,15 @@ lazy val output = project
2735
)
2836

2937
lazy val tests = project
38+
.settings(baseSettings)
3039
.settings(
3140
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
41+
scalafixTestkitOutputSourceDirectories :=
42+
sourceDirectories.in(output, Compile).value,
43+
scalafixTestkitInputSourceDirectories :=
44+
sourceDirectories.in(input, Compile).value,
45+
scalafixTestkitInputClasspath :=
46+
fullClasspath.in(input, Compile).value
4247
)
4348
.dependsOn(input, rules)
44-
.enablePlugins(BuildInfoPlugin)
49+
.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)