[Analysis API] render extra debug information for nested symbols if renders for outers

This commit is contained in:
Ilya Kirillov
2022-10-24 22:23:51 +02:00
committed by teamcity
parent 85effcc1b3
commit 4bb32f4634
77 changed files with 967 additions and 29 deletions
@@ -28,7 +28,7 @@ abstract class AbstractAnalysisApiAnnotationsOnTypesTest : AbstractAnalysisApiSi
appendLine("KtTypeReference: ${ktTypeReference.text}")
appendLine("annotations: [")
for (annotation in annotations) {
appendLine(DebugSymbolRenderer.renderAnnotationApplication(annotation).indented(indent = 2))
appendLine(DebugSymbolRenderer().renderAnnotationApplication(annotation).indented(indent = 2))
}
appendLine("]")
}
@@ -5,15 +5,17 @@
package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.annotations
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationsList
import org.jetbrains.kotlin.analysis.api.symbols.DebugSymbolRenderer
import org.jetbrains.kotlin.analysis.test.framework.utils.indented
object TestAnnotationRenderer {
context (KtAnalysisSession)
fun renderAnnotations(annotations: KtAnnotationsList) = buildString {
appendLine("annotations: [")
for (annotation in annotations.annotations) {
appendLine(DebugSymbolRenderer.renderAnnotationApplication(annotation).indented(indent = 2))
appendLine(DebugSymbolRenderer().renderAnnotationApplication(annotation).indented(indent = 2))
}
appendLine("]")
}
@@ -22,7 +22,7 @@ abstract class AbstractExpectedExpressionTypeTest : AbstractAnalysisApiSingleFil
val actualExpectedTypeText: String? = executeOnPooledThreadInReadAction {
analyseForTest(expressionAtCaret) {
val expectedType = expressionAtCaret.getExpectedType() ?: return@analyseForTest null
DebugSymbolRenderer.renderType(expectedType)
DebugSymbolRenderer().renderType(expectedType)
}
}
@@ -60,7 +60,7 @@ internal fun KtAnalysisSession.stringRepresentation(any: Any): String = with(any
is KtValueParameterSymbol -> "${if (isVararg) "vararg " else ""}$name: ${returnType.render()}"
is KtTypeParameterSymbol -> this.nameOrAnonymous.asString()
is KtVariableSymbol -> "${if (isVal) "val" else "var"} $name: ${returnType.render()}"
is KtSymbol -> DebugSymbolRenderer.render(this)
is KtSymbol -> DebugSymbolRenderer().render(this)
is Boolean -> toString()
is Map<*, *> -> if (isEmpty()) "{}" else entries.joinToString(
separator = ",\n ",
@@ -19,12 +19,12 @@ abstract class AbstractFileScopeTest : AbstractAnalysisApiSingleFileTest() {
analyseForTest(ktFile) {
val symbol = ktFile.getFileSymbol()
val scope = symbol.getFileScope()
with(DebugSymbolRenderer) {
val renderedSymbol = renderExtra(symbol)
with(DebugSymbolRenderer(renderExtra = true)) {
val renderedSymbol = render(symbol)
val callableNames = scope.getPossibleCallableNames()
val renderedCallables = scope.getCallableSymbols().map { renderExtra(it) }
val renderedCallables = scope.getCallableSymbols().map { render(it) }
val classifierNames = scope.getPossibleClassifierNames()
val renderedClassifiers = scope.getClassifierSymbols().map { renderExtra(it) }
val renderedClassifiers = scope.getClassifierSymbols().map { render(it) }
"FILE SYMBOL:\n" + renderedSymbol + "\n" +
"\nCALLABLE NAMES:\n" + callableNames.joinToString(prefix = "[", postfix = "]\n", separator = ", ") +
@@ -31,7 +31,7 @@ abstract class AbstractSubstitutionOverridesUnwrappingTest : AbstractSymbolTest(
}
override fun KtAnalysisSession.renderSymbolForComparison(symbol: KtSymbol): String {
return with(DebugSymbolRenderer) { renderForSubstitutionOverrideUnwrappingTest(symbol) }
return with(DebugSymbolRenderer()) { renderForSubstitutionOverrideUnwrappingTest(symbol) }
}
override fun configureTest(builder: TestConfigurationBuilder) {
@@ -86,7 +86,7 @@ abstract class AbstractTypeScopeTest : AbstractAnalysisApiSingleFileTest() {
val callables = scope.getCallableSymbols().toList()
return prettyPrint {
callables.forEach {
appendLine(DebugSymbolRenderer.render(it))
appendLine(DebugSymbolRenderer().render(it))
}
}
}
@@ -79,7 +79,7 @@ abstract class AbstractSymbolTest : AbstractAnalysisApiSingleFileTest() {
}
}
is KtReceiverParameterSymbol -> DebugSymbolRenderer.render(symbol)
is KtReceiverParameterSymbol -> DebugSymbolRenderer().render(symbol)
else -> error(symbol::class.toString())
}
)
@@ -147,7 +147,7 @@ abstract class AbstractSymbolTest : AbstractAnalysisApiSingleFileTest() {
}
protected open fun KtAnalysisSession.renderSymbolForComparison(symbol: KtSymbol): String {
return with(DebugSymbolRenderer) { renderExtra(symbol) }
return with(DebugSymbolRenderer(renderExtra = true)) { render(symbol) }
}
}