Skip to content

Commit

Permalink
chore: Adjust to changes in Scalafix
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Mar 9, 2024
1 parent 1c416ca commit 268d744
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .jvmopts
@@ -1,6 +1,6 @@
-Xss4m
-Xms1G
-Xmx2G
-Xmx3G
-XX:ReservedCodeCacheSize=1024m
-XX:+TieredCompilation
-Dfile.encoding=UTF-8
1 change: 1 addition & 0 deletions .scalafix3.conf
Expand Up @@ -11,3 +11,4 @@ OrganizeImports.groups = [
"scala.meta."
"*"
]
OrganizeImports.targetDialect = StandardLayout
Expand Up @@ -271,6 +271,7 @@ case class ScalafixProvider(
| OrganizeImports
|]
|OrganizeImports.removeUnused = false
|OrganizeImports.targetDialect = Scala3
|
|""".stripMargin
)
Expand Down Expand Up @@ -376,6 +377,7 @@ case class ScalafixProvider(
val classpath =
(targetRoot.toList ++ scalaTarget.fullClasspath).asJava

val isSource3 = scalaTarget.scalac.getOptions().contains("-Xsource:3")
for {
api <- getScalafix(scalaBinaryVersion)
urlClassLoaderWithExternalRule <- getRuleClassLoader(
Expand All @@ -389,7 +391,7 @@ case class ScalafixProvider(
if (scalaBinaryVersion == "2.13") list.add("-Wunused:imports")
else list.add("-Ywarn-unused-import")

if (!isScala3 && scalaTarget.scalac.getOptions().contains("-Xsource:3"))
if (!isScala3 && isSource3)
list.add("-Xsource:3")

// We always compile with synthetics:on but scalafix will fail if we don't set it here
Expand All @@ -402,7 +404,7 @@ case class ScalafixProvider(
.withScalaVersion(scalaVersion)
.withClasspath(classpath)
.withToolClasspath(urlClassLoaderWithExternalRule)
.withConfig(scalafixConf(isScala3).asJava)
.withConfig(scalafixConf(isScala3 || isSource3).asJava)
.withRules(rules.asJava)
.withPaths(List(diskFilePath.toNIO).asJava)
.withSourceroot(sourceroot.toNIO)
Expand Down
Expand Up @@ -212,23 +212,29 @@ class OrganizeImportsLspSuite
|import scala.concurrent.duration.*
|import scala.concurrent.{Future<<>> as ScalaFuture}
|import scala.concurrent.ExecutionContext.global
|import scala.concurrent.ExecutionContext
|
|object A {
| implicit val ec: ExecutionContext = global
| val d = Duration(10, MICROSECONDS)
| val k = ScalaFuture.successful(1)
| ScalaFuture{ println("Hello!") }
|}
|""".stripMargin,
s"${SourceOrganizeImports.title}",
"""
|package a
|import scala.concurrent.duration.*
|import scala.concurrent.{Future as ScalaFuture}
|
|object A {
| val d = Duration(10, MICROSECONDS)
| val k = ScalaFuture.successful(1)
|}
|""".stripMargin,
"""|package a
|import scala.concurrent.ExecutionContext
|import scala.concurrent.ExecutionContext.global
|import scala.concurrent.Future as ScalaFuture
|import scala.concurrent.duration.*
|
|object A {
| implicit val ec: ExecutionContext = global
| val d = Duration(10, MICROSECONDS)
| val k = ScalaFuture.successful(1)
| ScalaFuture{ println("Hello!") }
|}
|""".stripMargin,
kind = List(sourceKind),
scalacOptions = scalacOption ++ List("-Xsource:3"),
)
Expand Down

0 comments on commit 268d744

Please sign in to comment.