Skip to content

Commit e9aefaa

Browse files
Change main reflection to jvm Fields; use KReflection for built-ins
1 parent 79bebea commit e9aefaa

File tree

6 files changed

+343
-152
lines changed

6 files changed

+343
-152
lines changed

jupyter-lib/api/src/main/kotlin/org/jetbrains/kotlinx/jupyter/api/VariableState.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package org.jetbrains.kotlinx.jupyter.api
22

3-
import kotlin.reflect.KProperty
43
import kotlin.reflect.KProperty1
54
import kotlin.reflect.jvm.isAccessible
5+
import java.lang.reflect.Field
66

77
interface VariableState {
8-
val property: KProperty<*>
8+
// val property: KProperty<*>
9+
val property: Field
910
val scriptInstance: Any?
1011
val stringValue: String?
1112
val value: Result<Any?>
1213
}
1314

1415
data class VariableStateImpl(
15-
override val property: KProperty1<Any, *>,
16+
// override val property: KProperty1<Any, *>,
17+
override val property: Field,
1618
override val scriptInstance: Any,
1719
) : VariableState {
1820
private val stringCache = VariableStateCache<String?> {

src/main/kotlin/org/jetbrains/kotlinx/jupyter/repl/impl/InternalEvaluatorImpl.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import org.jetbrains.kotlinx.jupyter.exceptions.ReplCompilerException
1515
import org.jetbrains.kotlinx.jupyter.repl.ContextUpdater
1616
import org.jetbrains.kotlinx.jupyter.repl.InternalEvalResult
1717
import org.jetbrains.kotlinx.jupyter.repl.InternalEvaluator
18+
import java.lang.reflect.Field
19+
import java.lang.reflect.Modifier
1820
import org.jetbrains.kotlinx.jupyter.repl.InternalVariablesMarkersProcessor
1921
import kotlin.reflect.KMutableProperty1
2022
import kotlin.reflect.KProperty1
@@ -182,6 +184,10 @@ internal class InternalEvaluatorImpl(
182184
}
183185
}
184186

187+
private fun isValField(property: Field): Boolean {
188+
return property.modifiers and Modifier.FINAL != 0
189+
}
190+
185191
private fun updateDataAfterExecution(lastExecutionCellId: Int, resultValue: ResultValue) {
186192
variablesWatcher.ensureStorageCreation(lastExecutionCellId)
187193
variablesHolder += getVisibleVariables(resultValue, lastExecutionCellId)

0 commit comments

Comments
 (0)