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

dev.mokkery.plugin.core.TransformerScope.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.core

import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.name.ClassId

interface TransformerScope : CompilerPluginScope {

    val currentFile: IrFile

    val classes: MutableMap
    val functions: MutableMap
}

interface ClassResolver {
    fun resolve(context: IrPluginContext): IrClass
}

interface FunctionResolver {
    fun resolve(context: IrPluginContext): IrSimpleFunction
}

class FunctionById(private val id: CallableId) : FunctionResolver {
    override fun resolve(context: IrPluginContext): IrSimpleFunction = context.referenceFunctions(id).first().owner
}

class ClassById(private val id: ClassId) : ClassResolver {
    override fun resolve(context: IrPluginContext): IrClass = context.referenceClass(id)!!.owner
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy