[FIR] Allow to render function type with custom cone type renderer
This commit is contained in:
committed by
TeamCityServer
parent
13d8b10be0
commit
30bd39aabf
@@ -56,7 +56,7 @@ private fun ConeKotlinType.renderAttributes(): String {
|
|||||||
return attributes.joinToString(" ", postfix = " ") { it.toString() }
|
return attributes.joinToString(" ", postfix = " ") { it.toString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeTypeProjection.render(): String {
|
fun ConeTypeProjection.render(): String {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
ConeStarProjection -> "*"
|
ConeStarProjection -> "*"
|
||||||
is ConeKotlinTypeProjectionIn -> "in ${type.render()}"
|
is ConeKotlinTypeProjectionIn -> "in ${type.render()}"
|
||||||
@@ -65,8 +65,10 @@ private fun ConeTypeProjection.render(): String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ConeKotlinType.renderFunctionType(kind: FunctionClassKind?, isExtension: Boolean): String {
|
fun ConeKotlinType.renderFunctionType(
|
||||||
if (!kind.withPrettyRender()) return render()
|
kind: FunctionClassKind?, isExtension: Boolean, renderType: ConeTypeProjection.() -> String = { render() }
|
||||||
|
): String {
|
||||||
|
if (!kind.withPrettyRender()) return renderType()
|
||||||
return buildString {
|
return buildString {
|
||||||
if (kind == FunctionClassKind.SuspendFunction) {
|
if (kind == FunctionClassKind.SuspendFunction) {
|
||||||
append("suspend ")
|
append("suspend ")
|
||||||
@@ -79,12 +81,12 @@ fun ConeKotlinType.renderFunctionType(kind: FunctionClassKind?, isExtension: Boo
|
|||||||
val arguments = otherTypeArguments.subList(0, otherTypeArguments.size - 1)
|
val arguments = otherTypeArguments.subList(0, otherTypeArguments.size - 1)
|
||||||
val returnType = otherTypeArguments.last()
|
val returnType = otherTypeArguments.last()
|
||||||
if (receiver != null) {
|
if (receiver != null) {
|
||||||
append(receiver.render())
|
append(receiver.renderType())
|
||||||
append(".")
|
append(".")
|
||||||
}
|
}
|
||||||
append(arguments.joinToString(", ", "(", ")") { it.render() })
|
append(arguments.joinToString(", ", "(", ")") { it.renderType() })
|
||||||
append(" -> ")
|
append(" -> ")
|
||||||
append(returnType.render())
|
append(returnType.renderType())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user