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

dev.mokkery.plugin.fir.Utils.kt Maven / Gradle / Ivy

Go to download

Mokkery is a mocking library for Kotlin Multiplatform, easy to use, boilerplate-free and compiler plugin driven.

The newest version!
package dev.mokkery.plugin.fir

import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticParameterRenderer
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType


fun FirConstructorSymbol.isDefault() = valueParameterSymbols.isEmpty() || valueParameterSymbols.all { it.hasDefaultValue }

val FirRegularClassSymbol.constructors get() = declarationSymbols.filterIsInstance()

@Suppress("UNCHECKED_CAST")
fun FirDiagnosticRenderers.renderTypeCompat(): DiagnosticParameterRenderer = try {
    RENDER_TYPE
} catch (e: NoSuchMethodError) {
    FirDiagnosticRenderers::class
        .java
        .methods
        .first { it.name == "getRENDER_TYPE" }
        .invoke(this)
        .let { it as DiagnosticParameterRenderer }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy