io.gitlab.arturbosch.detekt.test.KotlinScriptEngine.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of detekt-test Show documentation
Show all versions of detekt-test Show documentation
Static code analysis for Kotlin
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