File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
src/main/kotlin/org/javacs/kt/compiler Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ dependencies {
40
40
implementation " org.jetbrains.kotlin:kotlin-compiler:$kotlinVersion "
41
41
implementation " org.jetbrains.kotlin:kotlin-scripting-compiler:$kotlinVersion "
42
42
implementation " org.jetbrains.kotlin:kotlin-scripting-jvm-host-unshaded:$kotlinVersion "
43
+ implementation ' org.jetbrains.kotlin:kotlin-sam-with-receiver-compiler-plugin'
43
44
implementation " org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion "
44
45
implementation ' org.jetbrains:fernflower:1.0'
45
46
implementation " org.jetbrains.exposed:exposed-core:$exposedVersion "
Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
69
69
import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
70
70
import org.jetbrains.kotlin.config.*
71
71
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
72
+ import org.jetbrains.kotlin.samWithReceiver.CliSamWithReceiverComponentContributor
73
+ import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
72
74
import java.io.File
73
75
74
76
private val GRADLE_DSL_DEPENDENCY_PATTERN = Regex (" ^gradle-(?:kotlin-dsl|core).*\\ .jar$" )
@@ -376,6 +378,12 @@ private class CompilationEnvironment(
376
378
configFiles = EnvironmentConfigFiles .JVM_CONFIG_FILES
377
379
)
378
380
381
+ // hacky way to support SamWithReceiverAnnotations for scripts
382
+ val scriptDefinitions: List <ScriptDefinition > = environment.configuration.getList(ScriptingConfigurationKeys .SCRIPT_DEFINITIONS )
383
+ scriptDefinitions.takeIf { it.isNotEmpty() }?.let {
384
+ val annotations = scriptDefinitions.flatMap { it.asLegacyOrNull<KotlinScriptDefinition >()?.annotationsForSamWithReceivers ? : emptyList() }
385
+ StorageComponentContainerContributor .registerExtension(environment.project, CliSamWithReceiverComponentContributor (annotations))
386
+ }
379
387
val project = environment.project
380
388
parser = KtPsiFactory (project)
381
389
scripts = ScriptDefinitionProvider .getInstance(project)!! as CliScriptDefinitionProvider
You can’t perform that action at this time.
0 commit comments