Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Renames and wildcard should not be separated #151

Merged
merged 1 commit into from
Jan 14, 2021
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
4 changes: 1 addition & 3 deletions input/src/main/scala/fix/GroupedImportsExplodeMixed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ package fix
import scala.collection.immutable._
import scala.collection.mutable.{Map, Seq => S, Buffer => _, _}

object GroupedImportsExplodeMixed {
val m: Map[Int, Int] = ???
}
object GroupedImportsExplodeMixed
7 changes: 2 additions & 5 deletions output/src/main/scala/fix/GroupedImportsExplodeMixed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package fix

import scala.collection.immutable._
import scala.collection.mutable.Map
import scala.collection.mutable.{Buffer => _, _}
import scala.collection.mutable.{Seq => S}
import scala.collection.mutable.{Buffer => _, Seq => S, _}

object GroupedImportsExplodeMixed {
val m: Map[Int, Int] = ???
}
object GroupedImportsExplodeMixed
7 changes: 3 additions & 4 deletions rules/src/main/scala/fix/OrganizeImports.scala
Original file line number Diff line number Diff line change
Expand Up @@ -720,17 +720,16 @@ object OrganizeImports {
importer :: Nil

case Importer(ref, Importees(names, renames, unimports, Some(wildcard))) =>
// When a wildcard exists, all unimports (if any) and the wildcard must appear in the same
// When a wildcard exists, all renames, unimports, and the wildcard must appear in the same
// importer, e.g.:
//
// import p.{A => _, B => _, C => D, E, _}
//
// should be rewritten into
//
// import p.{A => _, B => _, _}
// import p.{C => D}
// import p.{A => _, B => _, C => D, _}
// import p.E
val importeesList = (names ++ renames).map(_ :: Nil) :+ (unimports :+ wildcard)
val importeesList = names.map(_ :: Nil) :+ (renames ++ unimports :+ wildcard)
importeesList filter (_.nonEmpty) map (Importer(ref, _))

case importer =>
Expand Down