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

dev.mokkery.plugin.jvm.MokkeryClassGenerationExtension.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.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)
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy