Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KE2: Use the right language version #18064

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions java/kotlin-extractor2/src/main/kotlin/KotlinExtractor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.analysis.project.structure.builder.buildKtSdkModule
import org.jetbrains.kotlin.analysis.project.structure.builder.buildKtSourceModule
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.psi.*

Expand Down Expand Up @@ -181,6 +182,9 @@ fun doAnalysis(
lateinit var sourceModule: KaSourceModule
val k2args: K2JVMCompilerArguments = parseCommandLineArguments(args.toList())

// TODO: Collect the messages, and log them?
val ourLanguageVersionSettings = k2args.toLanguageVersionSettings(MessageCollector.NONE)

val session = buildStandaloneAnalysisAPISession {
registerProjectService(KotlinLifetimeTokenProvider::class.java, KotlinAlwaysAccessibleLifetimeTokenProvider())

Expand Down Expand Up @@ -210,6 +214,7 @@ fun doAnalysis(
)
sourceModule = addModule(
buildKtSourceModule {
languageVersionSettings = ourLanguageVersionSettings
addSourceRoots(k2args.freeArgs.map { Paths.get(it) })
addRegularDependency(sdk)
addRegularDependency(lib)
Expand Down