dev.mokkery.plugin.jvm.MokkeryClassGenerationExtension.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.jvm
import dev.mokkery.plugin.core.Mokkery
import dev.mokkery.plugin.messageCollectorCompat
import org.jetbrains.kotlin.backend.jvm.extensions.ClassGenerator
import org.jetbrains.kotlin.backend.jvm.extensions.ClassGeneratorExtension
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.ir.declarations.IrClass
class MokkeryClassGenerationExtension(
configuration: CompilerConfiguration
) : ClassGeneratorExtension {
private val collector = configuration.messageCollectorCompat
override fun generateClass(generator: ClassGenerator, declaration: IrClass?): ClassGenerator {
if (declaration == null) return generator
if (declaration.origin != Mokkery.Origin) return generator
return JvmParamAssertionSkippingGenerator(generator, collector)
}
}