From 70b8db190551d97911b75ad90c78b653191be6e7 Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Sat, 15 May 2021 01:21:49 +0200 Subject: [PATCH] Scala 3: RemoveUnused cannot work as compiler support is missing --- .../main/scala/ExpandRelativeRootPackage.scala | 1 + .../scala/OrganizeImportsRootPackage.scala | 1 + .../src/main/scala/fix/AlreadyOrganized.scala | 1 + .../src/main/scala/fix/BlankLinesManual.scala | 1 + .../src/main/scala/fix/CoalesceImportees.scala | 1 + .../scala/fix/CurlyBracedSingleImportee.scala | 5 ++++- .../main/scala/fix/DeduplicateImportees.scala | 5 ++++- input/src/main/scala/fix/ExpandRelative.scala | 1 + .../scala/fix/ExpandRelativeMultiGroups.scala | 1 + .../scala/fix/ExpandRelativeQuotedIdent.scala | 1 + .../scala/fix/ExpandRelativeRootPackage.scala | 1 + .../src/main/scala/fix/GlobalImportsOnly.scala | 5 ++++- ...GroupedImportsAggressiveMergeWildcard.scala | 1 + .../main/scala/fix/GroupedImportsExplode.scala | 5 ++++- .../scala/fix/GroupedImportsExplodeMixed.scala | 5 ++++- .../fix/GroupedImportsExplodeUnimport.scala | 5 ++++- .../main/scala/fix/GroupedImportsKeep.scala | 1 + .../main/scala/fix/GroupedImportsMerge.scala | 1 + .../scala/fix/GroupedImportsMergeDedup.scala | 1 + .../scala/fix/GroupedImportsMergeRenames.scala | 1 + .../fix/GroupedImportsMergeUnimports.scala | 1 + .../fix/GroupedImportsMergeWildcard.scala | 1 + input/src/main/scala/fix/Groups.scala | 1 + .../main/scala/fix/GroupsLongestMatch.scala | 1 + .../fix/ImportsOrderAsciiPreformatted.scala | 1 + .../src/main/scala/fix/ImportsOrderKeep.scala | 1 + .../scala/fix/ImportsOrderSymbolsFirst.scala | 1 + .../ImportsOrderSymbolsFirstPreformatted.scala | 1 + input/src/main/scala/fix/Inheritance.scala | 1 + .../fix/MergeImportsFormatPreserving.scala | 1 + input/src/main/scala/fix/NoImports.scala | 5 ++++- input/src/main/scala/fix/PresetDefault.scala | 1 + .../main/scala/fix/PresetIntelliJ_2020_3.scala | 1 + input/src/main/scala/fix/RelativeImports.scala | 1 + .../scala/fix/SortImportSelectorsAscii.scala | 1 + .../scala/fix/SortImportSelectorsKeep.scala | 3 ++- .../fix/SortImportSelectorsSymbolsFirst.scala | 1 + input/src/main/scala/fix/Suppression.scala | 1 + .../main/scala/fix/nested/NestedPackage.scala | 1 + .../fix/nested/NestedPackageWithBraces.scala | 5 ++++- .../{scala => scala-2}/fix/RemoveUnused.scala | 0 .../fix/RemoveUnusedDisabled.scala | 0 .../fix/RemoveUnusedLocal.scala | 0 .../fix/RemoveUnusedMixed.scala | 0 .../fix/RemoveUnusedRelative.scala | 0 rules/src/main/scala/fix/OrganizeImports.scala | 18 ++++++++++++++---- 46 files changed, 79 insertions(+), 13 deletions(-) rename inputUnusedImports/src/main/{scala => scala-2}/fix/RemoveUnused.scala (100%) rename inputUnusedImports/src/main/{scala => scala-2}/fix/RemoveUnusedDisabled.scala (100%) rename inputUnusedImports/src/main/{scala => scala-2}/fix/RemoveUnusedLocal.scala (100%) rename inputUnusedImports/src/main/{scala => scala-2}/fix/RemoveUnusedMixed.scala (100%) rename inputUnusedImports/src/main/{scala => scala-2}/fix/RemoveUnusedRelative.scala (100%) diff --git a/input/src/main/scala/ExpandRelativeRootPackage.scala b/input/src/main/scala/ExpandRelativeRootPackage.scala index d1ab6f6..24e5f15 100644 --- a/input/src/main/scala/ExpandRelativeRootPackage.scala +++ b/input/src/main/scala/ExpandRelativeRootPackage.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports { expandRelative = true groupedImports = Explode diff --git a/input/src/main/scala/OrganizeImportsRootPackage.scala b/input/src/main/scala/OrganizeImportsRootPackage.scala index edf32d0..7d30938 100644 --- a/input/src/main/scala/OrganizeImportsRootPackage.scala +++ b/input/src/main/scala/OrganizeImportsRootPackage.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groups = ["re:javax?\\.", "*", "scala."] */ import java.time.Clock diff --git a/input/src/main/scala/fix/AlreadyOrganized.scala b/input/src/main/scala/fix/AlreadyOrganized.scala index 6e7cf4f..6488ed4 100644 --- a/input/src/main/scala/fix/AlreadyOrganized.scala +++ b/input/src/main/scala/fix/AlreadyOrganized.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = Merge */ package fix diff --git a/input/src/main/scala/fix/BlankLinesManual.scala b/input/src/main/scala/fix/BlankLinesManual.scala index bcdd84f..f958454 100644 --- a/input/src/main/scala/fix/BlankLinesManual.scala +++ b/input/src/main/scala/fix/BlankLinesManual.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports { blankLines = Manual groups = [ diff --git a/input/src/main/scala/fix/CoalesceImportees.scala b/input/src/main/scala/fix/CoalesceImportees.scala index e061c5b..fef52dd 100644 --- a/input/src/main/scala/fix/CoalesceImportees.scala +++ b/input/src/main/scala/fix/CoalesceImportees.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports { groupedImports = Keep coalesceToWildcardImportThreshold = 3 diff --git a/input/src/main/scala/fix/CurlyBracedSingleImportee.scala b/input/src/main/scala/fix/CurlyBracedSingleImportee.scala index f4771b4..66eb557 100644 --- a/input/src/main/scala/fix/CurlyBracedSingleImportee.scala +++ b/input/src/main/scala/fix/CurlyBracedSingleImportee.scala @@ -1,4 +1,7 @@ -/* rules = [OrganizeImports] */ +/* +rules = [OrganizeImports] +OrganizeImports.removeUnused = false + */ package fix import scala.collection.{Map} diff --git a/input/src/main/scala/fix/DeduplicateImportees.scala b/input/src/main/scala/fix/DeduplicateImportees.scala index fa0421a..8b7fde2 100644 --- a/input/src/main/scala/fix/DeduplicateImportees.scala +++ b/input/src/main/scala/fix/DeduplicateImportees.scala @@ -1,4 +1,7 @@ -/* rules = [OrganizeImports] */ +/* +rules = [OrganizeImports] +OrganizeImports.removeUnused = false + */ package fix import scala.collection.immutable.Vector diff --git a/input/src/main/scala/fix/ExpandRelative.scala b/input/src/main/scala/fix/ExpandRelative.scala index 8fe5ebb..4f0081d 100644 --- a/input/src/main/scala/fix/ExpandRelative.scala +++ b/input/src/main/scala/fix/ExpandRelative.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.expandRelative = true */ package fix diff --git a/input/src/main/scala/fix/ExpandRelativeMultiGroups.scala b/input/src/main/scala/fix/ExpandRelativeMultiGroups.scala index 5c4cab0..e6e5a1c 100644 --- a/input/src/main/scala/fix/ExpandRelativeMultiGroups.scala +++ b/input/src/main/scala/fix/ExpandRelativeMultiGroups.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.expandRelative = true */ package fix diff --git a/input/src/main/scala/fix/ExpandRelativeQuotedIdent.scala b/input/src/main/scala/fix/ExpandRelativeQuotedIdent.scala index 59ed1ee..1ce6c7d 100644 --- a/input/src/main/scala/fix/ExpandRelativeQuotedIdent.scala +++ b/input/src/main/scala/fix/ExpandRelativeQuotedIdent.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.expandRelative = true */ package fix diff --git a/input/src/main/scala/fix/ExpandRelativeRootPackage.scala b/input/src/main/scala/fix/ExpandRelativeRootPackage.scala index 8591344..241c3e7 100644 --- a/input/src/main/scala/fix/ExpandRelativeRootPackage.scala +++ b/input/src/main/scala/fix/ExpandRelativeRootPackage.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.expandRelative = true */ package fix diff --git a/input/src/main/scala/fix/GlobalImportsOnly.scala b/input/src/main/scala/fix/GlobalImportsOnly.scala index e53d15f..58dc463 100644 --- a/input/src/main/scala/fix/GlobalImportsOnly.scala +++ b/input/src/main/scala/fix/GlobalImportsOnly.scala @@ -1,4 +1,7 @@ -/* rules = [OrganizeImports] */ +/* +rules = [OrganizeImports] +OrganizeImports.removeUnused = false + */ package fix import scala.collection.mutable diff --git a/input/src/main/scala/fix/GroupedImportsAggressiveMergeWildcard.scala b/input/src/main/scala/fix/GroupedImportsAggressiveMergeWildcard.scala index 56e442d..6cfa22d 100644 --- a/input/src/main/scala/fix/GroupedImportsAggressiveMergeWildcard.scala +++ b/input/src/main/scala/fix/GroupedImportsAggressiveMergeWildcard.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = AggressiveMerge */ package fix diff --git a/input/src/main/scala/fix/GroupedImportsExplode.scala b/input/src/main/scala/fix/GroupedImportsExplode.scala index a6e4c61..798752d 100644 --- a/input/src/main/scala/fix/GroupedImportsExplode.scala +++ b/input/src/main/scala/fix/GroupedImportsExplode.scala @@ -1,4 +1,7 @@ -/* rules = [OrganizeImports] */ +/* +rules = [OrganizeImports] +OrganizeImports.removeUnused = false + */ package fix import scala.collection.mutable.{ArrayBuffer, Buffer, StringBuilder} diff --git a/input/src/main/scala/fix/GroupedImportsExplodeMixed.scala b/input/src/main/scala/fix/GroupedImportsExplodeMixed.scala index 393df3a..9c20806 100644 --- a/input/src/main/scala/fix/GroupedImportsExplodeMixed.scala +++ b/input/src/main/scala/fix/GroupedImportsExplodeMixed.scala @@ -1,4 +1,7 @@ -/* rules = [OrganizeImports] */ +/* +rules = [OrganizeImports] +OrganizeImports.removeUnused = false + */ package fix import scala.collection.immutable._ diff --git a/input/src/main/scala/fix/GroupedImportsExplodeUnimport.scala b/input/src/main/scala/fix/GroupedImportsExplodeUnimport.scala index 7839816..83dfdb0 100644 --- a/input/src/main/scala/fix/GroupedImportsExplodeUnimport.scala +++ b/input/src/main/scala/fix/GroupedImportsExplodeUnimport.scala @@ -1,4 +1,7 @@ -/* rules = [OrganizeImports] */ +/* +rules = [OrganizeImports] +OrganizeImports.removeUnused = false + */ package fix import scala.collection.{Seq => _, _} diff --git a/input/src/main/scala/fix/GroupedImportsKeep.scala b/input/src/main/scala/fix/GroupedImportsKeep.scala index 694c536..dfcbb19 100644 --- a/input/src/main/scala/fix/GroupedImportsKeep.scala +++ b/input/src/main/scala/fix/GroupedImportsKeep.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = Keep */ package fix diff --git a/input/src/main/scala/fix/GroupedImportsMerge.scala b/input/src/main/scala/fix/GroupedImportsMerge.scala index 4c4ca03..ebb06c1 100644 --- a/input/src/main/scala/fix/GroupedImportsMerge.scala +++ b/input/src/main/scala/fix/GroupedImportsMerge.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = Merge */ package fix diff --git a/input/src/main/scala/fix/GroupedImportsMergeDedup.scala b/input/src/main/scala/fix/GroupedImportsMergeDedup.scala index ceed9a4..c7fcd5e 100644 --- a/input/src/main/scala/fix/GroupedImportsMergeDedup.scala +++ b/input/src/main/scala/fix/GroupedImportsMergeDedup.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = Merge */ package fix diff --git a/input/src/main/scala/fix/GroupedImportsMergeRenames.scala b/input/src/main/scala/fix/GroupedImportsMergeRenames.scala index 8be206f..3718c2a 100644 --- a/input/src/main/scala/fix/GroupedImportsMergeRenames.scala +++ b/input/src/main/scala/fix/GroupedImportsMergeRenames.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = Merge */ package fix diff --git a/input/src/main/scala/fix/GroupedImportsMergeUnimports.scala b/input/src/main/scala/fix/GroupedImportsMergeUnimports.scala index a85dd88..b1275c7 100644 --- a/input/src/main/scala/fix/GroupedImportsMergeUnimports.scala +++ b/input/src/main/scala/fix/GroupedImportsMergeUnimports.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = Merge */ package fix diff --git a/input/src/main/scala/fix/GroupedImportsMergeWildcard.scala b/input/src/main/scala/fix/GroupedImportsMergeWildcard.scala index 5f89bb3..0133646 100644 --- a/input/src/main/scala/fix/GroupedImportsMergeWildcard.scala +++ b/input/src/main/scala/fix/GroupedImportsMergeWildcard.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = Merge */ package fix diff --git a/input/src/main/scala/fix/Groups.scala b/input/src/main/scala/fix/Groups.scala index 71043e0..49050eb 100644 --- a/input/src/main/scala/fix/Groups.scala +++ b/input/src/main/scala/fix/Groups.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groups = ["re:javax?\\.", "*", "scala."] */ package fix diff --git a/input/src/main/scala/fix/GroupsLongestMatch.scala b/input/src/main/scala/fix/GroupsLongestMatch.scala index 3025b16..a556a29 100644 --- a/input/src/main/scala/fix/GroupsLongestMatch.scala +++ b/input/src/main/scala/fix/GroupsLongestMatch.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groups = ["re:javax?\\.", "scala.", "scala.util.", "*"] */ package fix diff --git a/input/src/main/scala/fix/ImportsOrderAsciiPreformatted.scala b/input/src/main/scala/fix/ImportsOrderAsciiPreformatted.scala index 62e0fef..d427384 100644 --- a/input/src/main/scala/fix/ImportsOrderAsciiPreformatted.scala +++ b/input/src/main/scala/fix/ImportsOrderAsciiPreformatted.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = Keep */ package fix diff --git a/input/src/main/scala/fix/ImportsOrderKeep.scala b/input/src/main/scala/fix/ImportsOrderKeep.scala index 0b560c4..ca93394 100644 --- a/input/src/main/scala/fix/ImportsOrderKeep.scala +++ b/input/src/main/scala/fix/ImportsOrderKeep.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports { groupedImports = Keep importSelectorsOrder = Keep diff --git a/input/src/main/scala/fix/ImportsOrderSymbolsFirst.scala b/input/src/main/scala/fix/ImportsOrderSymbolsFirst.scala index 7d6caae..cf2e42d 100644 --- a/input/src/main/scala/fix/ImportsOrderSymbolsFirst.scala +++ b/input/src/main/scala/fix/ImportsOrderSymbolsFirst.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports { groupedImports = Keep importSelectorsOrder = Keep diff --git a/input/src/main/scala/fix/ImportsOrderSymbolsFirstPreformatted.scala b/input/src/main/scala/fix/ImportsOrderSymbolsFirstPreformatted.scala index 1c8800d..0c1d9a3 100644 --- a/input/src/main/scala/fix/ImportsOrderSymbolsFirstPreformatted.scala +++ b/input/src/main/scala/fix/ImportsOrderSymbolsFirstPreformatted.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports { groupedImports = Keep importsOrder = SymbolsFirst diff --git a/input/src/main/scala/fix/Inheritance.scala b/input/src/main/scala/fix/Inheritance.scala index 818a6fb..97cfeaf 100644 --- a/input/src/main/scala/fix/Inheritance.scala +++ b/input/src/main/scala/fix/Inheritance.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.expandRelative = true */ package fix diff --git a/input/src/main/scala/fix/MergeImportsFormatPreserving.scala b/input/src/main/scala/fix/MergeImportsFormatPreserving.scala index 4c4958f..2ebc986 100644 --- a/input/src/main/scala/fix/MergeImportsFormatPreserving.scala +++ b/input/src/main/scala/fix/MergeImportsFormatPreserving.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = Merge */ diff --git a/input/src/main/scala/fix/NoImports.scala b/input/src/main/scala/fix/NoImports.scala index d1b549d..240aeaa 100644 --- a/input/src/main/scala/fix/NoImports.scala +++ b/input/src/main/scala/fix/NoImports.scala @@ -1,4 +1,7 @@ -/* rules = OrganizeImports */ +/* +rules = [OrganizeImports] +OrganizeImports.removeUnused = false + */ package fix object NoImports \ No newline at end of file diff --git a/input/src/main/scala/fix/PresetDefault.scala b/input/src/main/scala/fix/PresetDefault.scala index dba899e..5b5c1d6 100644 --- a/input/src/main/scala/fix/PresetDefault.scala +++ b/input/src/main/scala/fix/PresetDefault.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports { preset = DEFAULT groupedImports = Merge diff --git a/input/src/main/scala/fix/PresetIntelliJ_2020_3.scala b/input/src/main/scala/fix/PresetIntelliJ_2020_3.scala index ee66e39..76d2af9 100644 --- a/input/src/main/scala/fix/PresetIntelliJ_2020_3.scala +++ b/input/src/main/scala/fix/PresetIntelliJ_2020_3.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports { preset = INTELLIJ_2020_3 groupedImports = Explode diff --git a/input/src/main/scala/fix/RelativeImports.scala b/input/src/main/scala/fix/RelativeImports.scala index 00569bf..b49fa35 100644 --- a/input/src/main/scala/fix/RelativeImports.scala +++ b/input/src/main/scala/fix/RelativeImports.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groups = ["scala.", "*"] */ package fix diff --git a/input/src/main/scala/fix/SortImportSelectorsAscii.scala b/input/src/main/scala/fix/SortImportSelectorsAscii.scala index 5bb7c14..b6e22d8 100644 --- a/input/src/main/scala/fix/SortImportSelectorsAscii.scala +++ b/input/src/main/scala/fix/SortImportSelectorsAscii.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groupedImports = Keep */ package fix diff --git a/input/src/main/scala/fix/SortImportSelectorsKeep.scala b/input/src/main/scala/fix/SortImportSelectorsKeep.scala index b556aa8..584f9c2 100644 --- a/input/src/main/scala/fix/SortImportSelectorsKeep.scala +++ b/input/src/main/scala/fix/SortImportSelectorsKeep.scala @@ -1,5 +1,6 @@ /* -rules = OrganizeImports +rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports { importSelectorsOrder = Keep groupedImports = Keep diff --git a/input/src/main/scala/fix/SortImportSelectorsSymbolsFirst.scala b/input/src/main/scala/fix/SortImportSelectorsSymbolsFirst.scala index 04e1843..56f0024 100644 --- a/input/src/main/scala/fix/SortImportSelectorsSymbolsFirst.scala +++ b/input/src/main/scala/fix/SortImportSelectorsSymbolsFirst.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports { importSelectorsOrder = SymbolsFirst groupedImports = Keep diff --git a/input/src/main/scala/fix/Suppression.scala b/input/src/main/scala/fix/Suppression.scala index b2aaa11..fce30cf 100644 --- a/input/src/main/scala/fix/Suppression.scala +++ b/input/src/main/scala/fix/Suppression.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groups = ["re:javax?\\.", "*", "scala."] */ package fix diff --git a/input/src/main/scala/fix/nested/NestedPackage.scala b/input/src/main/scala/fix/nested/NestedPackage.scala index 14e35a0..fd29e06 100644 --- a/input/src/main/scala/fix/nested/NestedPackage.scala +++ b/input/src/main/scala/fix/nested/NestedPackage.scala @@ -1,5 +1,6 @@ /* rules = [OrganizeImports] +OrganizeImports.removeUnused = false OrganizeImports.groups = ["re:javax?\\.", "*", "scala."] */ package fix diff --git a/input/src/main/scala/fix/nested/NestedPackageWithBraces.scala b/input/src/main/scala/fix/nested/NestedPackageWithBraces.scala index 416f114..6bffeec 100644 --- a/input/src/main/scala/fix/nested/NestedPackageWithBraces.scala +++ b/input/src/main/scala/fix/nested/NestedPackageWithBraces.scala @@ -1,4 +1,7 @@ -/* rules = [OrganizeImports] */ +/* +rules = [OrganizeImports] +OrganizeImports.removeUnused = false + */ package fix { package nested { import java.time.Clock diff --git a/inputUnusedImports/src/main/scala/fix/RemoveUnused.scala b/inputUnusedImports/src/main/scala-2/fix/RemoveUnused.scala similarity index 100% rename from inputUnusedImports/src/main/scala/fix/RemoveUnused.scala rename to inputUnusedImports/src/main/scala-2/fix/RemoveUnused.scala diff --git a/inputUnusedImports/src/main/scala/fix/RemoveUnusedDisabled.scala b/inputUnusedImports/src/main/scala-2/fix/RemoveUnusedDisabled.scala similarity index 100% rename from inputUnusedImports/src/main/scala/fix/RemoveUnusedDisabled.scala rename to inputUnusedImports/src/main/scala-2/fix/RemoveUnusedDisabled.scala diff --git a/inputUnusedImports/src/main/scala/fix/RemoveUnusedLocal.scala b/inputUnusedImports/src/main/scala-2/fix/RemoveUnusedLocal.scala similarity index 100% rename from inputUnusedImports/src/main/scala/fix/RemoveUnusedLocal.scala rename to inputUnusedImports/src/main/scala-2/fix/RemoveUnusedLocal.scala diff --git a/inputUnusedImports/src/main/scala/fix/RemoveUnusedMixed.scala b/inputUnusedImports/src/main/scala-2/fix/RemoveUnusedMixed.scala similarity index 100% rename from inputUnusedImports/src/main/scala/fix/RemoveUnusedMixed.scala rename to inputUnusedImports/src/main/scala-2/fix/RemoveUnusedMixed.scala diff --git a/inputUnusedImports/src/main/scala/fix/RemoveUnusedRelative.scala b/inputUnusedImports/src/main/scala-2/fix/RemoveUnusedRelative.scala similarity index 100% rename from inputUnusedImports/src/main/scala/fix/RemoveUnusedRelative.scala rename to inputUnusedImports/src/main/scala-2/fix/RemoveUnusedRelative.scala diff --git a/rules/src/main/scala/fix/OrganizeImports.scala b/rules/src/main/scala/fix/OrganizeImports.scala index 2ab606f..381d8c9 100644 --- a/rules/src/main/scala/fix/OrganizeImports.scala +++ b/rules/src/main/scala/fix/OrganizeImports.scala @@ -60,7 +60,7 @@ class OrganizeImports(config: OrganizeImportsConfig) extends SemanticRule("Organ config.conf .getOrElse("OrganizeImports")(OrganizeImportsConfig()) .andThen(patchPreset(_, config.conf)) - .andThen(checkScalacOptions(_, config.scalacOptions)) + .andThen(checkScalacOptions(_, config.scalacOptions, config.scalaVersion)) override def fix(implicit doc: SemanticDocument): Patch = { unusedImporteePositions ++= doc.diagnostics.collect { @@ -614,9 +614,12 @@ object OrganizeImports { private def checkScalacOptions( conf: OrganizeImportsConfig, - scalacOptions: List[String] + scalacOptions: List[String], + scalaVersion: String ): Configured[Rule] = { - val hasWarnUnused = { + val hasCompilerSupport = scalaVersion.startsWith("2") + + val hasWarnUnused = hasCompilerSupport && { val warnUnusedPrefix = Set("-Wunused", "-Ywarn-unused") val warnUnusedString = Set("-Xlint", "-Xlint:unused") scalacOptions exists { option => @@ -626,13 +629,20 @@ object OrganizeImports { if (!conf.removeUnused || hasWarnUnused) Configured.ok(new OrganizeImports(conf)) - else + else if (hasCompilerSupport) Configured.error( "The Scala compiler option \"-Ywarn-unused\" is required to use OrganizeImports with" + " \"OrganizeImports.removeUnused\" set to true. To fix this problem, update your" + " build to use at least one Scala compiler option like -Ywarn-unused-import (2.11" + " only), -Ywarn-unused, -Xlint:unused (2.12.2 or above) or -Wunused (2.13 only)." ) + else + Configured.error( + "\"OrganizeImports.removeUnused\" is not supported on Scala 3 as the compiler is" + + " not providing enough information. Run the rule with" + + " \"OrganizeImports.removeUnused\" set to false to organize imports while keeping" + + " potentially unused imports." + ) } private def buildImportMatchers(config: OrganizeImportsConfig): Seq[ImportMatcher] = {