Scripting: notify writer in REPL on errors reporting complete
required for restoring compatibility with IDE REPL usages (scratch files included), since IDE counterpart needs a reliable signal when the processing of the REPL snippet/command is completed
This commit is contained in:
@@ -27,6 +27,8 @@ enum class ReplEscapeType {
|
||||
COMPILE_ERROR,
|
||||
RUNTIME_ERROR,
|
||||
INTERNAL_ERROR,
|
||||
ERRORS_REPORTED, // should be send after reporting all errors caused by the current command
|
||||
// e.g. IDE uses it to recognize the end of command processing
|
||||
SUCCESS;
|
||||
|
||||
companion object {
|
||||
|
||||
+12
-3
@@ -139,10 +139,19 @@ class ReplFromTerminal(
|
||||
writer.outputCommandResult(tryInterpretResultAsValueClass(evalResult) ?: evalResult.toString())
|
||||
}
|
||||
}
|
||||
is ReplEvalResult.Error.Runtime -> if (evalResult.message.isNotEmpty()) writer.outputRuntimeError(evalResult.message)
|
||||
is ReplEvalResult.Error.CompileTime -> if (evalResult.message.isNotEmpty()) writer.outputCompileError(evalResult.message)
|
||||
is ReplEvalResult.Error.Runtime -> {
|
||||
if (evalResult.message.isNotEmpty()) writer.outputRuntimeError(evalResult.message)
|
||||
writer.notifyErrorsReported()
|
||||
}
|
||||
is ReplEvalResult.Error.CompileTime -> {
|
||||
if (evalResult.message.isNotEmpty()) writer.outputCompileError(evalResult.message)
|
||||
writer.notifyErrorsReported()
|
||||
}
|
||||
is ReplEvalResult.Incomplete -> writer.notifyIncomplete()
|
||||
is ReplEvalResult.HistoryMismatch -> {} // assuming handled elsewhere
|
||||
is ReplEvalResult.HistoryMismatch -> {
|
||||
// assuming that internal error reported elsewhere
|
||||
writer.notifyErrorsReported()
|
||||
}
|
||||
}
|
||||
return evalResult
|
||||
}
|
||||
|
||||
+1
@@ -17,4 +17,5 @@ class ConsoleReplWriter : ReplWriter {
|
||||
override fun notifyIncomplete() {}
|
||||
override fun notifyCommandSuccess() {}
|
||||
override fun sendInternalErrorReport(x: String) {}
|
||||
override fun notifyErrorsReported() {}
|
||||
}
|
||||
|
||||
+1
@@ -40,4 +40,5 @@ class IdeSystemOutWrapperReplWriter(standardOut: PrintStream) : PrintStream(stan
|
||||
override fun outputCompileError(x: String) = printlnWithEscaping(x, COMPILE_ERROR)
|
||||
override fun outputRuntimeError(x: String) = printlnWithEscaping(x, RUNTIME_ERROR)
|
||||
override fun sendInternalErrorReport(x: String) = printlnWithEscaping(x, INTERNAL_ERROR)
|
||||
override fun notifyErrorsReported() = printlnWithEscaping("", ERRORS_REPORTED)
|
||||
}
|
||||
|
||||
+1
@@ -16,4 +16,5 @@ interface ReplWriter {
|
||||
fun outputCompileError(x: String)
|
||||
fun outputRuntimeError(x: String)
|
||||
fun sendInternalErrorReport(x: String)
|
||||
fun notifyErrorsReported()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user