org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderers.kt Maven / Gradle / Ivy
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.diagnostics
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.diagnostics.rendering.ContextIndependentParameterRenderer
import org.jetbrains.kotlin.diagnostics.rendering.Renderer
object KtDiagnosticRenderers {
val NULLABLE_STRING = Renderer { it ?: "null" }
val TO_STRING = Renderer { element: Any? ->
element.toString()
}
val EMPTY = Renderer { _: Any? -> "" }
val VISIBILITY = Renderer { visibility: Visibility ->
visibility.externalDisplayName
}
val NOT_RENDERED = Renderer {
""
}
val FUNCTION_PARAMETERS = Renderer { hasValueParameters: Boolean -> if (hasValueParameters) "..." else "" }
@Suppress("FunctionName")
fun COLLECTION(renderer: ContextIndependentParameterRenderer): ContextIndependentParameterRenderer> {
return Renderer { list ->
list.joinToString(prefix = "[", postfix = "]", separator = ", ", limit = 3, truncated = "...") {
renderer.render(it)
}
}
}
}