File tree Expand file tree Collapse file tree 7 files changed +23
-3
lines changed
api/src/main/kotlin/org/jetbrains/kotlinx/jupyter/api
lib/src/main/kotlin/jupyter/kotlin
main/kotlin/org/jetbrains/kotlinx/jupyter
test/kotlin/org/jetbrains/kotlinx/jupyter/test Expand file tree Collapse file tree 7 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ class BuildSettingsExtension(private val project: Project) {
49
49
fun skipPrereleaseCheck () = args.add(" -Xskip-prerelease-check" )
50
50
fun requiresOptIn () = args.add(" -Xopt-in=kotlin.RequiresOptIn" )
51
51
fun allowResultReturnType () = args.add(" -Xallow-result-return-type" )
52
+ fun useOldBackend () = args.add(" -Xuse-old-backend" )
53
+
54
+ fun samConversions (type : String ) = args.add(" -Xsam-conversions=$type " )
55
+ fun samConversionsClass () = samConversions(" class" )
52
56
}
53
57
54
58
fun withCompilerArgs (configure : KotlinCompilerArgsBuilder .() -> Unit ) {
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ buildSettings {
75
75
withLanguageLevel(rootSettings.kotlinLanguageLevel)
76
76
withCompilerArgs {
77
77
skipPrereleaseCheck()
78
+ samConversionsClass()
78
79
}
79
80
withTests()
80
81
}
Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ interface Notebook {
22
22
*/
23
23
val cellVariables: Map <Int , Set <String >>
24
24
25
+ /* *
26
+ * Returns the object that allows to access execution results
27
+ */
28
+ val resultsAccessor: ResultsAccessor
29
+
25
30
/* *
26
31
* Mapping allowing to get cell by execution number
27
32
*/
Original file line number Diff line number Diff line change @@ -30,9 +30,7 @@ abstract class ScriptTemplateWithDisplayHelpers(
30
30
USE (o.getDefinitions(notebook).single())
31
31
}
32
32
33
- val Out : ResultsAccessor get() = ResultsAccessor { id ->
34
- notebook.getResult(id)
35
- }
33
+ val Out : ResultsAccessor get() = notebook.resultsAccessor
36
34
37
35
val JavaRuntimeUtils get() = notebook.jreInfo
38
36
}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import org.jetbrains.kotlinx.jupyter.api.JREInfoProvider
9
9
import org.jetbrains.kotlinx.jupyter.api.KotlinKernelVersion
10
10
import org.jetbrains.kotlinx.jupyter.api.Notebook
11
11
import org.jetbrains.kotlinx.jupyter.api.RenderersProcessor
12
+ import org.jetbrains.kotlinx.jupyter.api.ResultsAccessor
12
13
import org.jetbrains.kotlinx.jupyter.api.VariableState
13
14
import org.jetbrains.kotlinx.jupyter.repl.InternalEvaluator
14
15
@@ -110,6 +111,8 @@ class NotebookImpl(
110
111
override val cellVariables: Map <Int , Set <String >>
111
112
get() = currentCellVariables
112
113
114
+ override val resultsAccessor = ResultsAccessor { getResult(it) }
115
+
113
116
override fun getCell (id : Int ): CodeCellImpl {
114
117
return cells[id] ? : throw ArrayIndexOutOfBoundsException (
115
118
" There is no cell with number '$id '"
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import kotlin.script.experimental.api.SourceCode
24
24
import kotlin.test.assertEquals
25
25
import kotlin.test.assertFails
26
26
import kotlin.test.assertFalse
27
+ import kotlin.test.assertNotNull
27
28
import kotlin.test.fail
28
29
29
30
class ReplTests : AbstractSingleReplTest () {
@@ -455,6 +456,12 @@ class ReplTests : AbstractSingleReplTest() {
455
456
@Suppress(" UNCHECKED_CAST" )
456
457
assertEquals(2 , (res as (Int ) -> Int )(1 ))
457
458
}
459
+
460
+ @Test
461
+ fun testOutVarRendering () {
462
+ val res = eval(" Out" ).resultValue
463
+ assertNotNull(res)
464
+ }
458
465
}
459
466
460
467
class ReplVarsTest : AbstractSingleReplTest () {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import org.jetbrains.kotlinx.jupyter.api.JREInfoProvider
13
13
import org.jetbrains.kotlinx.jupyter.api.KotlinKernelVersion
14
14
import org.jetbrains.kotlinx.jupyter.api.Notebook
15
15
import org.jetbrains.kotlinx.jupyter.api.RenderersProcessor
16
+ import org.jetbrains.kotlinx.jupyter.api.ResultsAccessor
16
17
import org.jetbrains.kotlinx.jupyter.api.VariableState
17
18
import org.jetbrains.kotlinx.jupyter.api.VariableStateImpl
18
19
import org.jetbrains.kotlinx.jupyter.api.libraries.ExecutionHost
@@ -162,6 +163,7 @@ object NotebookMock : Notebook {
162
163
get() = emptyList()
163
164
override val variablesState = mutableMapOf<String , VariableStateImpl >()
164
165
override val cellVariables = mapOf<Int , Set <String >>()
166
+ override val resultsAccessor = ResultsAccessor { getResult(it) }
165
167
166
168
override fun getCell (id : Int ): CodeCellImpl {
167
169
return cells[id] ? : throw ArrayIndexOutOfBoundsException (
You can’t perform that action at this time.
0 commit comments