Gavin Ray
12/15/2023, 2:47 PMdmitriy.novozhilov
12/15/2023, 2:52 PM2.0.0-Beta1
K2 compiler is used by default
So all you need is just use the compiler from the eap channel and ensure that you didn't manually set languageVersion
to 1.9
anywhere in your configurationdmitriy.novozhilov
12/15/2023, 2:52 PM2.0.0-Beta2
was released todayGavin Ray
12/15/2023, 2:54 PMIncrementalFirJvmCompilerRunner
I am interested in building some tooling using the K2/FIR compiler and analysis API's 😃Gavin Ray
12/15/2023, 2:55 PMdmitriy.novozhilov
12/15/2023, 2:58 PMK2JVMCompiler
class, it's the main entrypoint for CLI version of kotlinc
dmitriy.novozhilov
12/15/2023, 2:59 PMIncrementalFirJvmCompilerRunner
is much harder and I suspect that the only user of this entrypoint is Kotlin Gradle Plugin
So you can check its sourcesGavin Ray
12/15/2023, 2:59 PMGavin Ray
12/15/2023, 3:00 PMdmitriy.novozhilov
12/15/2023, 3:01 PMdmitriy.novozhilov
12/15/2023, 3:02 PMI think the Gradle Tooling API should make the Gradle part simpler, hopefully?Sorry, don't know about it
Gavin Ray
12/15/2023, 3:06 PMGavin Ray
12/15/2023, 5:58 PMProject: {ALL_SCOPE_KEY=com.intellij.psi.search.EverythingGlobalScope@3}
Analyzing module: example, files are:
[KtFile: example.kt]
fun compileAndAnalyzeKotlinFiles() {
val standaloneAnalysisAPISession = buildStandaloneAnalysisAPISession {
buildKtModuleProvider {
val jvmTarget = JvmTarget.DEFAULT
this.platform = JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget)
addModule(
buildKtSourceModule {
this.moduleName = "example"
this.platform = JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget)
val projectPath = "kotlinprojects/example/src/main/kotlin"
val examplePath = ClassLoader.getSystemClassLoader().getResource(projectPath)
?: error("Could not find resource $projectPath")
this.addSourceRoot(Path.of(examplePath.toURI()))
}
)
}
}
println("Project: ${standaloneAnalysisAPISession.project}")
standaloneAnalysisAPISession.modulesWithFiles.forEach { (ktSourceModule: KtSourceModule, psiFiles: List<PsiFile>) ->
println(" Analyzing module: ${ktSourceModule.moduleName}, files are:")
println(" $psiFiles")
}
}