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

main.seskar.compiler.specialname.backend.JsSpecialName.kt Maven / Gradle / Ivy

There is a newer version: 3.32.0
Show newest version
package seskar.compiler.specialname.backend

import org.jetbrains.kotlin.ir.declarations.IrDeclarationBase
import org.jetbrains.kotlin.ir.expressions.IrConst
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.util.getAnnotation
import org.jetbrains.kotlin.name.FqName

private val JS_SPECIAL_NAME = FqName("seskar.js.JsSpecialName")

private fun IrConstructorCall.value(): String {
    val argument = getValueArgument(0) as IrConst<*>
    return argument.value as String
}

internal fun IrDeclarationBase.specialName(): String? {
    val name = getAnnotation(JS_SPECIAL_NAME)
        ?: return null

    return name.value()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy