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

Fix importer order when sorting by ASCII #149

Merged
merged 1 commit into from
Jan 13, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/target/
.DS_Store
.bloop/
.bsp/
.idea/
Expand Down
2 changes: 1 addition & 1 deletion output/src/main/scala/fix/DeduplicateImportees.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fix

import scala.collection.immutable.Vector
import scala.collection.immutable.{Set => _, _}
import scala.collection.immutable.{Map => Dict}
import scala.collection.immutable.{Set => _, _}

object DeduplicateImportees
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fix

import fix.MergeImports.Wildcard1.{d, _}
import fix.MergeImports.Wildcard1.{b => B}
import fix.MergeImports.Wildcard1.{d, _}
import fix.MergeImports.Wildcard2.{a, b, _}

object GroupedImportsMergeWildcard
6 changes: 3 additions & 3 deletions rules/src/main/scala/fix/OrganizeImports.scala
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class OrganizeImports(config: OrganizeImportsConfig) extends SemanticRule("Organ
// single line.
//
// See https://github.com/liancheng/scalafix-organize-imports/issues/84 for more details.
case ImportsOrder.Ascii => importeesSorted sortBy (_.copy().syntax)
case ImportsOrder.Ascii => importeesSorted sortBy (i => importerSyntax(i.copy()))
case ImportsOrder.SymbolsFirst => sortImportersSymbolsFirst(importeesSorted)
case ImportsOrder.Keep => importeesSorted
}
Expand Down Expand Up @@ -651,7 +651,7 @@ object OrganizeImports {

private def prettyPrintImportGroup(group: Seq[Importer]): String =
group
.map(i => "import " + fixedImporterSyntax(i))
.map(i => "import " + importerSyntax(i))
.mkString("\n")

/**
Expand All @@ -661,7 +661,7 @@ object OrganizeImports {
* users do want the inserted spaces, Scalafmt should be used after running the `OrganizeImports`
* rule.
*/
private def fixedImporterSyntax(importer: Importer): String =
private def importerSyntax(importer: Importer): String =
importer.pos match {
case pos: Position.Range =>
// Position found, implies that `importer` was directly parsed from the source code. Returns
Expand Down