dev.mokkery.plugin.fir.Utils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mokkery-plugin Show documentation
Show all versions of mokkery-plugin Show documentation
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 }
}