[LC] render all type annotations in tests

^KT-66603
This commit is contained in:
Dmitrii Gridin
2024-03-15 17:15:55 +01:00
committed by Space Team
parent 66d1839d20
commit 3c8a95e623
38 changed files with 615 additions and 143 deletions
@@ -38,8 +38,6 @@ class PsiClassRenderer private constructor(
}
companion object {
var extendedTypeRenderer: ThreadLocal<Boolean> = ThreadLocal.withInitial { false }
fun renderClass(
psiClass: PsiClass,
renderInner: Boolean = false,
@@ -84,8 +82,9 @@ class PsiClassRenderer private constructor(
}
private fun PsiType.renderType() = StringBuffer().also { renderType(it) }.toString()
private fun PsiType.renderType(sb: StringBuffer) {
if (extendedTypeRenderer.get() && annotations.isNotEmpty()) {
if (annotations.isNotEmpty()) {
sb.append(annotations.joinToString(" ", postfix = " ") { it.renderAnnotation() })
}
when (this) {
@@ -108,8 +107,24 @@ class PsiClassRenderer private constructor(
componentType.renderType(sb)
sb.append("[]")
}
is PsiWildcardType -> {
if (!isBounded) {
sb.append("?")
} else {
if (isSuper) {
sb.append(PsiWildcardType.SUPER_PREFIX)
} else {
sb.append(PsiWildcardType.EXTENDS_PREFIX)
}
bound?.renderType(sb)
}
}
is PsiPrimitiveType -> {
sb.append(name)
}
else -> {
sb.append(canonicalText)
sb.append(getCanonicalText(/* annotated = */ true))
}
}
}