[FIR] Render dot-separated FQNs instead of slash-separated ones in diagnostics

^KT-62030 fixed
This commit is contained in:
Ilya Kirillov
2023-09-21 20:19:46 +02:00
committed by Space Team
parent b119b4de02
commit d98da87278
92 changed files with 146 additions and 130 deletions
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.renderer
import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.name.ClassId
class ConeIdRendererForDiagnostics : ConeIdRenderer() {
override fun renderClassId(classId: ClassId) {
builder.append(classId.asFqNameString())
}
override fun renderCallableId(callableId: CallableId) {
builder.append(callableId.asSingleFqName().asString())
}
}
@@ -38,7 +38,7 @@ class ConeTypeRendererForReadability(
return "$lowerRendered!"
}
val kotlinCollectionsPrefix = StandardNames.COLLECTIONS_PACKAGE_FQ_NAME.asString().replace(".", "/") + "/"
val kotlinCollectionsPrefix = StandardNames.COLLECTIONS_PACKAGE_FQ_NAME.asString() + "."
val mutablePrefix = "Mutable"
// java.util.List<Foo> -> (Mutable)List<Foo!>!
val simpleCollection = replacePrefixesInTypeRepresentations(
@@ -59,7 +59,7 @@ class ConeTypeRendererForReadability(
)
if (mutableEntry != null) return mutableEntry
val kotlinPrefix = StandardNames.BUILT_INS_PACKAGE_FQ_NAME.asString() + "/"
val kotlinPrefix = StandardNames.BUILT_INS_PACKAGE_FQ_NAME.asString() + "."
// Foo[] -> Array<(out) Foo!>!
val array = replacePrefixesInTypeRepresentations(
lowerRendered = lowerRendered,
@@ -5,10 +5,7 @@
package org.jetbrains.kotlin.fir.types
import org.jetbrains.kotlin.fir.renderer.ConeIdRendererForDebugging
import org.jetbrains.kotlin.fir.renderer.ConeIdShortRenderer
import org.jetbrains.kotlin.fir.renderer.ConeTypeRendererForDebugging
import org.jetbrains.kotlin.fir.renderer.ConeTypeRendererForReadability
import org.jetbrains.kotlin.fir.renderer.*
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.types.Variance
@@ -127,7 +124,7 @@ fun ConeKotlinType.renderReadable(): String {
fun ConeKotlinType.renderReadableWithFqNames(): String {
val builder = StringBuilder()
ConeTypeRendererForReadability(builder) { ConeIdRendererForDebugging() }.render(this)
ConeTypeRendererForReadability(builder) { ConeIdRendererForDiagnostics() }.render(this)
return builder.toString()
}