-
Notifications
You must be signed in to change notification settings - Fork 333
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
scalafix 0.13.0 #6807
scalafix 0.13.0 #6807
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -51,7 +51,7 @@ case class ScalafixProvider( | |||||
buildHasErrors: AbsolutePath => Boolean, | ||||||
)(implicit ec: ExecutionContext, rc: ReportContext) { | ||||||
import ScalafixProvider._ | ||||||
private val scalafixCache = TrieMap.empty[ScalaBinaryVersion, Scalafix] | ||||||
private val scalafixCache = TrieMap.empty[ScalaVersion, Scalafix] | ||||||
private val rulesClassloaderCache = | ||||||
TrieMap.empty[ScalafixRulesClasspathKey, URLClassLoader] | ||||||
|
||||||
|
@@ -242,6 +242,8 @@ case class ScalafixProvider( | |||||
|OrganizeImports.removeUnused = true | ||||||
|OrganizeImports.targetDialect = Scala3 | ||||||
| | ||||||
|ExplicitResultTypes.fetchScala3CompilerArtifactsOnVersionMismatch = true | ||||||
| | ||||||
|""".stripMargin | ||||||
) | ||||||
path.toFile().deleteOnExit() | ||||||
|
@@ -257,6 +259,8 @@ case class ScalafixProvider( | |||||
|OrganizeImports.removeUnused = false | ||||||
|OrganizeImports.targetDialect = Scala3 | ||||||
| | ||||||
|ExplicitResultTypes.fetchScala3CompilerArtifactsOnVersionMismatch = true | ||||||
| | ||||||
|""".stripMargin | ||||||
) | ||||||
path.toFile().deleteOnExit() | ||||||
|
@@ -379,7 +383,7 @@ case class ScalafixProvider( | |||||
} | ||||||
|
||||||
val result = for { | ||||||
api <- getScalafix(scalaBinaryVersion) | ||||||
api <- getScalafix(scalaTarget.scalaVersion) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping 2.13 by default for community rules via metals/metals/src/main/scala/scala/meta/internal/metals/ScalafixProvider.scala Lines 343 to 344 in f1ba8c5
|
||||||
urlClassLoaderWithExternalRule <- getRuleClassLoader( | ||||||
scalafixRulesKey, | ||||||
api.getClass.getClassLoader, | ||||||
|
@@ -484,7 +488,8 @@ case class ScalafixProvider( | |||||
val isScala3Dialect = isScala3 || isScalaSource | ||||||
val canRemoveUnused = !isScala3 || | ||||||
// https://github.com/scala/scala3/pull/17835 | ||||||
Seq("3.0", "3.1", "3.2", "3.3") | ||||||
// https://github.com/scala/scala3/pull/20315 | ||||||
Seq("3.0", "3.1", "3.2", "3.3.0", "3.3.1", "3.3.2", "3.3.3") | ||||||
.forall(v => !scalaVersion.startsWith(v)) | ||||||
val confFile = scalafixConf(isScala3Dialect, canRemoveUnused) | ||||||
confFile match { | ||||||
|
@@ -569,15 +574,15 @@ case class ScalafixProvider( | |||||
} | ||||||
|
||||||
private def getScalafix( | ||||||
scalaBinaryVersion: ScalaBinaryVersion | ||||||
scalaVersion: ScalaVersion | ||||||
): Future[Scalafix] = Future { | ||||||
scalafixCache.getOrElseUpdate( | ||||||
scalaBinaryVersion, { | ||||||
scalaVersion, { | ||||||
workDoneProgress.trackBlocking("Downloading scalafix") { | ||||||
val scalafix = | ||||||
if (scalaBinaryVersion == "2.11") scala211Fallback | ||||||
if (scalaVersion.startsWith("2.11")) scala211Fallback | ||||||
else | ||||||
Scalafix.fetchAndClassloadInstance(scalaBinaryVersion) | ||||||
Scalafix.fetchAndClassloadInstance(scalaVersion) | ||||||
scalafix | ||||||
} | ||||||
}, | ||||||
|
@@ -613,11 +618,11 @@ case class ScalafixProvider( | |||||
val rulesDependencies = scalfixRulesKey.usedRulesWithClasspath | ||||||
val organizeImportRule = | ||||||
// Scalafix version that supports Scala 2.11 doesn't have the rule built in | ||||||
if (scalfixRulesKey.scalaBinaryVersion == "2.11") | ||||||
if (scalfixRulesKey.scalaVersion.startsWith("2.11")) | ||||||
Some( | ||||||
Dependency.of( | ||||||
"com.github.liancheng", | ||||||
"organize-imports_" + scalfixRulesKey.scalaBinaryVersion, | ||||||
"organize-imports_2.11", | ||||||
"0.6.0", | ||||||
) | ||||||
) | ||||||
|
@@ -677,11 +682,10 @@ case class ScalafixProvider( | |||||
|
||||||
object ScalafixProvider { | ||||||
|
||||||
type ScalaBinaryVersion = String | ||||||
type ScalaVersion = String | ||||||
|
||||||
case class ScalafixRulesClasspathKey( | ||||||
scalaBinaryVersion: ScalaBinaryVersion, | ||||||
scalaVersion: ScalaVersion, | ||||||
usedRulesWithClasspath: Set[Dependency], | ||||||
) | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scalacenter/scalafix@c2afbcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users of ExplicitResultTypes will most likely have a custom cone anyway, but I guess it doesn't hurt to put it there