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

io.gitlab.arturbosch.detekt.test.KotlinScriptEngine.kt Maven / Gradle / Ivy

There is a newer version: 1.23.7
Show newest version
package io.gitlab.arturbosch.detekt.test

import org.intellij.lang.annotations.Language
import javax.script.ScriptException

/**
 * The object to use the Kotlin script engine for code compilation.
 */
object KotlinScriptEngine {

    /**
     * Compiles a given code string with the Jsr223 script engine.
     * If a compilation error occurs the script engine is recovered.
     * Afterwards this method throws a [KotlinScriptException].
     */
    fun compile(@Language("kotlin") code: String) {
        try {
            KotlinScriptEnginePool.getEngine().compile(code)
        } catch (e: ScriptException) {
            KotlinScriptEnginePool.recoverEngine()
            throw KotlinScriptException(e)
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy