diff --git a/scalafix/input/src/main/scala/org/typelevel/fix/v0_5Tests.scala b/scalafix/input/src/main/scala/org/typelevel/fix/v0_5Tests.scala index 611ed36..ebf02b9 100644 --- a/scalafix/input/src/main/scala/org/typelevel/fix/v0_5Tests.scala +++ b/scalafix/input/src/main/scala/org/typelevel/fix/v0_5Tests.scala @@ -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._ diff --git a/scalafix/output/src/main/scala/org/typelevel/fix/v0_5Tests.scala b/scalafix/output/src/main/scala/org/typelevel/fix/v0_5Tests.scala index 5532d0a..91cff09 100644 --- a/scalafix/output/src/main/scala/org/typelevel/fix/v0_5Tests.scala +++ b/scalafix/output/src/main/scala/org/typelevel/fix/v0_5Tests.scala @@ -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 diff --git a/scalafix/rules/src/main/scala/fix/v0_5.scala b/scalafix/rules/src/main/scala/fix/v0_5.scala index 4d4f674..d8fea20 100644 --- a/scalafix/rules/src/main/scala/fix/v0_5.scala +++ b/scalafix/rules/src/main/scala/fix/v0_5.scala @@ -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 }