Implement params to pass args to generic and remote repls to support script templates with params

This commit is contained in:
Ilya Chernikov
2016-09-22 11:36:19 +02:00
parent f0d2f458e0
commit 43037373d7
6 changed files with 30 additions and 7 deletions
@@ -35,7 +35,9 @@ open class KotlinRemoteReplClientBase(
targetPlatform: CompileService.TargetPlatform,
templateClasspath: List<File>,
templateClassName: String,
compilerMessagesOutputStream: OutputStream,
scriptArgs: Array<Any?>? = null,
scriptArgsTypes: Array<Class<*>>? = null,
compilerMessagesOutputStream: OutputStream = System.err,
evalOutputStream: OutputStream? = null,
evalErrorStream: OutputStream? = null,
evalInputStream: InputStream? = null,
@@ -49,6 +51,8 @@ open class KotlinRemoteReplClientBase(
CompilerCallbackServicesFacadeServer(port = port),
templateClasspath,
templateClassName,
scriptArgs,
scriptArgsTypes,
RemoteOutputStreamServer(compilerMessagesOutputStream, port),
evalOutputStream?.let { RemoteOutputStreamServer(it, port) },
evalErrorStream?.let { RemoteOutputStreamServer(it, port) },
@@ -104,6 +108,8 @@ class KotlinRemoteReplEvaluator(
targetPlatform: CompileService.TargetPlatform,
templateClasspath: List<File>,
templateClassName: String,
scriptArgs: Array<Any?>?,
scriptArgsTypes: Array<Class<*>>?,
compilerMessagesOutputStream: OutputStream,
evalOutputStream: OutputStream?,
evalErrorStream: OutputStream?,
@@ -117,6 +123,8 @@ class KotlinRemoteReplEvaluator(
targetPlatform = targetPlatform,
templateClasspath = templateClasspath,
templateClassName = templateClassName,
scriptArgs = scriptArgs,
scriptArgsTypes = scriptArgsTypes,
compilerMessagesOutputStream = compilerMessagesOutputStream,
evalOutputStream = evalOutputStream,
evalErrorStream = evalErrorStream,
@@ -132,6 +132,8 @@ interface CompileService : Remote {
servicesFacade: CompilerCallbackServicesFacade,
templateClasspath: List<File>,
templateClassName: String,
scriptArgs: Array<Any?>?,
scriptArgsTypes: Array<Class<*>>?,
compilerMessagesOutputStream: RemoteOutputStream,
evalOutputStream: RemoteOutputStream?,
evalErrorStream: RemoteOutputStream?,
@@ -273,6 +273,8 @@ class CompileServiceImpl(
servicesFacade: CompilerCallbackServicesFacade,
templateClasspath: List<File>,
templateClassName: String,
scriptArgs: Array<Any?>?,
scriptArgsTypes: Array<Class<*>>?,
compilerMessagesOutputStream: RemoteOutputStream,
evalOutputStream: RemoteOutputStream?,
evalErrorStream: RemoteOutputStream?,
@@ -283,7 +285,7 @@ class CompileServiceImpl(
CompileService.CallResult.Error("Sorry, only JVM target platform is supported now")
else {
val disposable = Disposer.newDisposable()
val repl = KotlinJvmReplService(disposable, templateClasspath, templateClassName, compilerMessagesOutputStream, evalOutputStream, evalErrorStream, evalInputStream, operationsTracer)
val repl = KotlinJvmReplService(disposable, templateClasspath, templateClassName, scriptArgs, scriptArgsTypes, compilerMessagesOutputStream, evalOutputStream, evalErrorStream, evalInputStream, operationsTracer)
val sessionId = leaseSessionImpl(ClientOrSessionProxy(aliveFlagPath, repl, disposable))
CompileService.CallResult.Good(sessionId)
@@ -42,6 +42,8 @@ open class KotlinJvmReplService(
disposable: Disposable,
templateClasspath: List<File>,
templateClassName: String,
scriptArgs: Array<Any?>?,
scriptArgsTypes: Array<Class<*>>?,
compilerOutputStreamProxy: RemoteOutputStream,
evalOutputStream: RemoteOutputStream?,
evalErrorStream: RemoteOutputStream?,
@@ -115,8 +117,8 @@ open class KotlinJvmReplService(
private val compiledEvaluator : GenericReplCompiledEvaluator by lazy {
if (evalOutputStream == null && evalErrorStream == null && evalInputStream == null)
GenericReplCompiledEvaluator(configuration.jvmClasspathRoots, null)
else object : GenericReplCompiledEvaluator(configuration.jvmClasspathRoots, null) {
GenericReplCompiledEvaluator(configuration.jvmClasspathRoots, null, scriptArgs, scriptArgsTypes)
else object : GenericReplCompiledEvaluator(configuration.jvmClasspathRoots, null, scriptArgs, scriptArgsTypes) {
val out = PrintStream(BufferedOutputStream(RemoteOutputStreamClient(evalOutputStream!!, DummyProfiler()), REMOTE_STREAM_BUFFER_SIZE))
val err = PrintStream(BufferedOutputStream(RemoteOutputStreamClient(evalErrorStream!!, DummyProfiler()), REMOTE_STREAM_BUFFER_SIZE))
val `in` = BufferedInputStream(RemoteInputStreamClient(evalInputStream!!, DummyProfiler()), REMOTE_STREAM_BUFFER_SIZE)