Skip to content
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

Improve the 0.5.x migration some more by handling TpolecatPlugin.autoImport.ScalacOptions #166

Merged
merged 1 commit into from
Aug 1, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.github.davidgregory084.{ScalaVersion => Version}
import io.github.davidgregory084.{DevMode => Dev}
import io.github.davidgregory084.TpolecatPlugin._
import io.github.davidgregory084.TpolecatPlugin.autoImport
import io.github.davidgregory084.TpolecatPlugin.autoImport.ScalacOptions
import io.github.davidgregory084.TpolecatPlugin.autoImport._
import io.github.davidgregory084.TpolecatPlugin.autoImport.{ tpolecatCiModeEnvVar, scalacOptionsFor }
import io.github.davidgregory084._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import org.typelevel.sbt.tpolecat.{ DevMode => Dev, TpolecatPlugin, _ }
import org.typelevel.sbt.tpolecat.TpolecatPlugin.{ autoImport, _ }
import org.typelevel.sbt.tpolecat.TpolecatPlugin.autoImport.{ scalacOptionsFor, tpolecatCiModeEnvVar, _ }
import org.typelevel.scalacoptions.{ ScalaVersion => Version, ScalacOption, _ }
import org.typelevel.scalacoptions.{ ScalaVersion => Version, ScalacOption, ScalacOptions, _ }
import org.typelevel.scalacoptions.ScalaVersion.{ V2_11_0, _ }
import org.typelevel.scalacoptions.ScalacOptions.{ checkInit, _ }
// format: on
Expand Down
18 changes: 15 additions & 3 deletions scalafix/rules/src/main/scala/fix/v0_5.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,23 @@ class v0_5 extends SemanticRule("v0_5") {
// Handle imports from `io.github.davidgregory084.ScalaVersion`
case importer @ Importer(ref, importees) if ScalaVersionSym.matches(ref) =>
handleImports(importees, makeScalaVersionObjectImport)
// Handle imports from `io.github.davidgregory084.TpolecatPlugin.autoImport`
case importer @ Importer(ref, importees) if TpolecatPluginAutoImportSym.matches(ref) =>
handleImports(importees, makeAutoImportObjectImport)
// Handle imports from `io.github.davidgregory084.TpolecatPlugin.ScalacOptions`
case importer @ Importer(ref, importees) if TpolecatPluginScalacOptionsSym.matches(ref) =>
handleImports(importees, makeScalacOptionsObjectImport)
// Handle imports from `io.github.davidgregory084.TpolecatPlugin.autoImport`
case importer @ Importer(ref, importees) if TpolecatPluginAutoImportSym.matches(ref) =>
importees.collect {
// The `ScalacOptions` object moved to `scalac-options`
case importee @ Importee.Name(name) if TpolecatPluginScalacOptionsSym.matches(name) =>
makeScalacOptionsImport(importee) + Patch.removeImportee(importee)
case rename @ Importee.Rename(name, _) if TpolecatPluginScalacOptionsSym.matches(name) =>
makeScalacOptionsImport(rename) + Patch.removeImportee(rename)
case importee @ Importee.Name(name) =>
makeAutoImportObjectImport(importee) + Patch.removeImportee(importee)
case rename @ Importee.Rename(name, _) =>
makeAutoImportObjectImport(rename) + Patch.removeImportee(rename)
case importee @ Importee.Wildcard() =>
makeAutoImportObjectImport(importee) + Patch.removeImportee(importee)
}.asPatch
}.asPatch
}