[Analysis API FIR] fix containing declaration for value parameter

now it should also work for non-source declarations
This commit is contained in:
Ilya Kirillov
2022-11-18 18:04:33 +01:00
parent 7781ad67d4
commit f775778efa
6 changed files with 21 additions and 4 deletions
@@ -152,6 +152,7 @@ internal fun KtAnalysisSession.compareCalls(call1: KtCall, call2: KtCall): Int {
context(KtAnalysisSession)
internal fun renderScopeWithParentDeclarations(scope: KtScope): String = prettyPrint {
fun KtSymbol.qualifiedNameString() = when (this) {
is KtConstructorSymbol -> "<constructor> ${containingClassIdIfNonLocal?.asString()}"
is KtClassLikeSymbol -> classIdIfNonLocal!!.asString()
is KtCallableSymbol -> callableIdIfNonLocal!!.toString()
else -> error("unknown symbol $this")
@@ -179,5 +180,17 @@ internal fun renderScopeWithParentDeclarations(scope: KtScope): String = prettyP
}
}
}
if (symbol is KtFunctionLikeSymbol && symbol.valueParameters.isNotEmpty()) {
appendLine()
withIndent {
printCollection(symbol.valueParameters, separator = "\n") { typeParameter ->
val containingDeclarationForValueParameter = typeParameter.getContainingSymbol()
append(typeParameter.render(renderingOptions))
append(" from ")
append(containingDeclarationForValueParameter?.qualifiedNameString())
}
}
}
}
}