Skip to content

Commit

Permalink
Make order of renames and missing imports deterministic (#19468)
Browse files Browse the repository at this point in the history
Fixes #19467
  • Loading branch information
bishabosha committed Jan 19, 2024
2 parents 0b7a785 + 92a3f26 commit 36ee954
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import org.eclipse.lsp4j.TextEdit
* A type printer that shortens types by replacing fully qualified names with shortened versions.
*
* The printer supports symbol renames found in scope and will use the rename if it is available.
* It also handlse custom renames as specified in the `renameConfigMap` parameter.
* It also handle custom renames as specified in the `renameConfigMap` parameter.
*/
class ShortenedTypePrinter(
symbolSearch: SymbolSearch,
Expand All @@ -45,7 +45,7 @@ class ShortenedTypePrinter(
isTextEdit: Boolean = false,
renameConfigMap: Map[Symbol, String] = Map.empty
)(using indexedCtx: IndexedContext, reportCtx: ReportContext) extends RefinedPrinter(indexedCtx.ctx):
private val missingImports: mutable.Set[ImportSel] = mutable.Set.empty
private val missingImports: mutable.Set[ImportSel] = mutable.LinkedHashSet.empty
private val defaultWidth = 1000

private val methodFlags =
Expand All @@ -62,9 +62,9 @@ class ShortenedTypePrinter(
AbsOverride,
Lazy
)
private val foundRenames = collection.mutable.Map.empty[Symbol, String]

private val foundRenames = collection.mutable.LinkedHashMap.empty[Symbol, String]

def getUsedRenamesInfo(using Context): List[String] =
foundRenames.map { (from, to) =>
s"type $to = ${from.showName}"
Expand Down Expand Up @@ -190,7 +190,7 @@ class ShortenedTypePrinter(

override protected def selectionString(tp: NamedType): String =
indexedCtx.rename(tp.symbol) match
case Some(value) =>
case Some(value) =>
foundRenames += tp.symbol -> value
value
case None => super.selectionString(tp)
Expand Down

0 comments on commit 36ee954

Please sign in to comment.