1
1
package org.jetbrains.kotlin.jupyter
2
2
3
- import jupyter.kotlin.DependsOn
4
3
import jupyter.kotlin.KotlinContext
5
- import jupyter.kotlin.Repository
6
- import jupyter.kotlin.ScriptTemplateWithDisplayHelpers
7
4
import kotlinx.coroutines.runBlocking
8
5
import org.jetbrains.kotlin.config.KotlinCompilerVersion
9
6
import org.jetbrains.kotlin.jupyter.api.Code
@@ -15,6 +12,9 @@ import org.jetbrains.kotlin.jupyter.api.KotlinKernelVersion
15
12
import org.jetbrains.kotlin.jupyter.api.LibraryDefinition
16
13
import org.jetbrains.kotlin.jupyter.api.Renderable
17
14
import org.jetbrains.kotlin.jupyter.api.RendererTypeHandler
15
+ import org.jetbrains.kotlin.jupyter.config.DependsOn
16
+ import org.jetbrains.kotlin.jupyter.config.Repository
17
+ import org.jetbrains.kotlin.jupyter.config.getCompilationConfiguration
18
18
import org.jetbrains.kotlin.jupyter.libraries.LibrariesProcessor
19
19
import org.jetbrains.kotlin.jupyter.libraries.LibraryFactory
20
20
import org.jetbrains.kotlin.jupyter.libraries.buildDependenciesInitCode
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.jupyter.repl.KotlinCompleter
26
26
import org.jetbrains.kotlin.jupyter.repl.ListErrorsResult
27
27
import org.jetbrains.kotlin.jupyter.repl.SourceCodeImpl
28
28
import org.jetbrains.kotlin.scripting.ide_services.compiler.KJvmReplCompilerWithIdeServices
29
- import org.jetbrains.kotlin.scripting.resolve.skipExtensionsResolutionForImplicitsExceptInnermost
30
29
import java.io.File
31
30
import java.net.URLClassLoader
32
31
import java.util.LinkedList
@@ -43,25 +42,16 @@ import kotlin.script.experimental.api.ScriptEvaluationConfiguration
43
42
import kotlin.script.experimental.api.analysisDiagnostics
44
43
import kotlin.script.experimental.api.asDiagnostics
45
44
import kotlin.script.experimental.api.asSuccess
46
- import kotlin.script.experimental.api.baseClass
47
- import kotlin.script.experimental.api.compilerOptions
48
45
import kotlin.script.experimental.api.constructorArgs
49
- import kotlin.script.experimental.api.defaultImports
50
46
import kotlin.script.experimental.api.dependencies
51
- import kotlin.script.experimental.api.fileExtension
52
47
import kotlin.script.experimental.api.foundAnnotations
53
- import kotlin.script.experimental.api.hostConfiguration
54
48
import kotlin.script.experimental.api.implicitReceivers
55
49
import kotlin.script.experimental.api.onSuccess
56
- import kotlin.script.experimental.api.refineConfiguration
57
50
import kotlin.script.experimental.api.valueOrThrow
58
- import kotlin.script.experimental.host.withDefaultsFrom
59
51
import kotlin.script.experimental.jvm.BasicJvmReplEvaluator
60
52
import kotlin.script.experimental.jvm.JvmDependency
61
53
import kotlin.script.experimental.jvm.baseClassLoader
62
- import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration
63
54
import kotlin.script.experimental.jvm.jvm
64
- import kotlin.script.experimental.jvm.updateClasspath
65
55
import kotlin.script.experimental.jvm.util.isError
66
56
import kotlin.script.experimental.jvm.util.isIncomplete
67
57
import kotlin.script.experimental.jvm.util.toSourceCodePosition
@@ -295,34 +285,8 @@ class ReplForJupyterImpl(
295
285
}
296
286
297
287
private val compilerConfiguration by lazy {
298
- ScriptCompilationConfiguration {
299
- hostConfiguration.update { it.withDefaultsFrom(defaultJvmScriptingHostConfiguration) }
300
- baseClass.put(KotlinType (ScriptTemplateWithDisplayHelpers ::class ))
301
- fileExtension.put(" jupyter.kts" )
302
-
303
- val classImports = listOf (
304
- DependsOn ::class ,
305
- Repository ::class ,
306
- ScriptTemplateWithDisplayHelpers ::class ,
307
- ).map { it.java.name }
308
- defaultImports(classImports + defaultGlobalImports)
309
-
310
- jvm {
311
- updateClasspath(scriptClasspath)
312
- }
313
- refineConfiguration {
314
- onAnnotations(DependsOn ::class , Repository ::class , handler = { configureMavenDepsOnAnnotations(it) })
315
- }
316
-
317
- val receiversTypes = scriptReceivers.map { KotlinType (it.javaClass.canonicalName) }
318
- implicitReceivers(receiversTypes)
319
- skipExtensionsResolutionForImplicitsExceptInnermost(receiversTypes)
320
-
321
- compilerOptions(
322
- " -jvm-target" ,
323
- runtimeProperties.jvmTargetForSnippets,
324
- " -no-stdlib"
325
- )
288
+ getCompilationConfiguration(scriptClasspath, scriptReceivers, runtimeProperties.jvmTargetForSnippets) {
289
+ onAnnotations(DependsOn ::class , Repository ::class , handler = { configureMavenDepsOnAnnotations(it) })
326
290
}
327
291
}
328
292
0 commit comments