Scripting: switch legacy CLI REPL to the new infrastructure

This commit is contained in:
Ilya Chernikov
2022-05-13 20:44:44 +02:00
committed by teamcity
parent 6784cb63aa
commit b36d1be5f8
16 changed files with 185 additions and 62 deletions
@@ -57,8 +57,13 @@ class BasicJvmReplEvaluator(val scriptEvaluator: ScriptEvaluator = BasicJvmScrip
}
KJvmEvaluatedSnippet(snippetVal, currentConfiguration, retVal)
}
else ->
KJvmEvaluatedSnippet(snippetVal, currentConfiguration, ResultValue.NotEvaluated)
else -> {
val firstError = evalRes.reports.find { it.isError() }
KJvmEvaluatedSnippet(
snippetVal, currentConfiguration,
firstError?.exception?.let { ResultValue.Error(it) } ?: ResultValue.NotEvaluated
)
}
}
val newNode = lastEvaluatedSnippet.add(newEvalRes)
@@ -5,6 +5,7 @@
package kotlin.script.experimental.jvm.util
import java.io.ByteArrayOutputStream
import java.io.PrintStream
import kotlin.script.experimental.api.ResultValue
@@ -42,3 +43,11 @@ fun ResultValue.Error.renderError(stream: PrintStream) {
}
}
}
fun ResultValue.Error.renderError(): String =
ByteArrayOutputStream().use { os ->
val ps = PrintStream(os)
renderError(ps)
ps.flush()
os.toString()
}