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

Commit

Permalink
Renames and wildcard should not be separated (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
liancheng authored Jan 14, 2021
1 parent 7e8f5c3 commit 574bc20
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
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

0 comments on commit 574bc20

Please sign in to comment.