@@ -5,7 +5,9 @@ import com.beust.klaxon.JsonObject
5
5
import com.beust.klaxon.Parser
6
6
import com.beust.klaxon.int
7
7
import com.beust.klaxon.string
8
- import org.jetbrains.kotlin.cli.common.KotlinVersion
8
+ import org.jetbrains.kotlin.cli.common.repl.ReplCheckResult
9
+ import org.jetbrains.kotlin.cli.common.repl.ReplEvalResult
10
+ import org.jetbrains.kotlin.config.KotlinCompilerVersion
9
11
import java.io.File
10
12
import java.util.concurrent.atomic.AtomicLong
11
13
import kotlin.concurrent.thread
@@ -111,7 +113,7 @@ fun JupyterConnection.Socket.shellMessagesHandler(msg: Message, repl: ReplForJup
111
113
content = jsonObject(
112
114
" protocol_version" to protocolVersion,
113
115
" language" to " Kotlin" ,
114
- " language_version" to KotlinVersion .VERSION ,
116
+ " language_version" to KotlinCompilerVersion .VERSION ,
115
117
" language_info" to jsonObject(" name" to " kotlin" , " file_extension" to " kt" )
116
118
)))
117
119
" history_request" ->
@@ -126,7 +128,7 @@ fun JupyterConnection.Socket.shellMessagesHandler(msg: Message, repl: ReplForJup
126
128
" connect_request" ->
127
129
send(makeReplyMessage(msg, " connection_reply" ,
128
130
content = jsonObject(JupyterSockets .values()
129
- .map { Pair (" ${it.name} _port" , connection.config.ports[it.ordinal]) })))
131
+ .map { Pair (" ${it.name} _port" , connection.config.ports[it.ordinal]) })))
130
132
" execute_request" -> {
131
133
connection.contextMessage = msg
132
134
val count = executionCount.getAndIncrement()
@@ -138,7 +140,7 @@ fun JupyterConnection.Socket.shellMessagesHandler(msg: Message, repl: ReplForJup
138
140
" execution_count" to count,
139
141
" code" to code)))
140
142
val res = if (isCommand(code.toString())) runCommand(code.toString(), repl)
141
- else (repl?.eval(count, code.toString()) ? : ReplForJupyter . EvalResult . Error .Runtime (" no repl!" )).asResult
143
+ else (connection.evalWithIO { repl?.eval(count, code.toString()) ? : ReplEvalResult . Error .Runtime (emptyList(), " no repl!" ) } ).asResult
142
144
send(makeReplyMessage(msg, " execute_result" , content = jsonObject(
143
145
" execution_count" to count,
144
146
" data" to res,
@@ -157,17 +159,17 @@ fun JupyterConnection.Socket.shellMessagesHandler(msg: Message, repl: ReplForJup
157
159
" user_variables" to JsonObject (),
158
160
" payload" to listOf<String >(),
159
161
" user_expressions" to JsonObject ())
160
- ))
162
+ ))
161
163
connection.contextMessage = null
162
164
}
163
165
" is_complete_request" -> {
164
166
val code = msg.content[" code" ].toString()
165
167
val resStr = if (isCommand(code)) " complete" else {
166
168
val res = repl?.checkComplete(executionCount.get(), code)
167
169
when (res) {
168
- is ReplForJupyter . EvalResult .Error -> " invalid"
169
- is ReplForJupyter . EvalResult .Incomplete -> " incomplete"
170
- is ReplForJupyter . EvalResult . Ready -> " complete"
170
+ is ReplCheckResult .Error -> " invalid"
171
+ is ReplCheckResult .Incomplete -> " incomplete"
172
+ is ReplCheckResult . Ok -> " complete"
171
173
null -> " error: no repl"
172
174
else -> throw Exception (" unexpected result from checkComplete call: $res " )
173
175
}
0 commit comments