Skip to content

Commit

Permalink
Backport "Make order of renames and missing imports deterministic" to…
Browse files Browse the repository at this point in the history
… LTS (#20842)

Backports #19468 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jun 28, 2024
2 parents 2152d15 + b7b89a2 commit 9842c9e
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 9842c9e

Please # to comment.