[VISUALIZER] Replace rendering of class with no name to anonymous

This commit is contained in:
Ivan Kylchik
2021-02-19 16:31:56 +03:00
committed by TeamCityServer
parent ca424a94ef
commit 813e48ffb4
4 changed files with 6 additions and 4 deletions
@@ -130,8 +130,8 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
stack.pop()
}
is KtClassOrObject -> {
if (element.isLocal) stack.addName((element.name ?: "<no name provided>"))
stack.push((element.name ?: "<no name provided>"))
if (element.isLocal) stack.addName((element.name ?: "<anonymous>"))
stack.push((element.name ?: "<anonymous>"))
element.acceptChildren(this)
stack.pop()
}
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.compiler.visualizer.Annotator.annotate
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
import org.jetbrains.kotlin.renderer.ClassifierNamePolicy
@@ -257,6 +258,7 @@ class PsiVisualizer(private val file: KtFile, analysisResult: AnalysisResult) :
}
fun renderType(type: KotlinType): String {
if (type.toString() == SpecialNames.NO_NAME_PROVIDED.asString()) return "<anonymous>"
return typeRenderer.renderType(type)
}
@@ -1,6 +1,6 @@
// FIR_IGNORE
fun test() {
// test.<no name provided>
// <anonymous>
// │
val x = object {}
}
@@ -31,7 +31,7 @@ fun withLocals(p: Int): Int {
// │ fun (Any).hashCode(): Int
// │ │
fun foo() = hashCode()
// fun (withLocals.<no name provided>).foo(): Int
// fun (<anonymous>).foo(): Int
// │
}).foo()