Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make order of renames and missing imports deterministic #19468

Merged
merged 1 commit into from
Jan 19, 2024
Merged
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
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
Loading