Fix params handling in JSR 223 for Idea, add simple test

This commit is contained in:
Ilya Chernikov
2016-09-23 13:30:07 +02:00
parent 6da7276510
commit 063fbed75e
3 changed files with 52 additions and 3 deletions
@@ -33,7 +33,9 @@ class KotlinJvmJsr223ScriptEngine4Idea(
disposable: Disposable,
private val factory: ScriptEngineFactory,
templateClasspath: List<File>,
templateClassName: String
templateClassName: String,
scriptArgs: Array<Any?>?,
scriptArgsTypes: Array<Class<*>>?
) : AbstractScriptEngine(), ScriptEngine {
private val daemon by lazy {
@@ -61,7 +63,7 @@ class KotlinJvmJsr223ScriptEngine4Idea(
}
}
val localEvaluator by lazy { GenericReplCompiledEvaluator(emptyList(), Thread.currentThread().contextClassLoader) }
val localEvaluator by lazy { GenericReplCompiledEvaluator(emptyList(), Thread.currentThread().contextClassLoader, scriptArgs, scriptArgsTypes) }
private var lineCount = 0
@@ -38,7 +38,9 @@ class KotlinJvmJsr223StandardScriptEngineFactory4Idea : ScriptEngineFactory {
Disposer.newDisposable(),
this,
listOf(PathUtil.getKotlinPathsForIdeaPlugin().runtimePath),
"kotlin.script.StandardScriptTemplate")
"kotlin.script.StandardScriptTemplate",
arrayOf(emptyArray<String>()),
null)
override fun getOutputStatement(toDisplay: String?): String = "print(\"$toDisplay\")"
override fun getMethodCallSyntax(obj: String, m: String, vararg args: String): String = "$obj.$m(${args.joinToString()})"