All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderers.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-Beta1
Show newest version
/*
 * 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)
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy