[Analysis API] Add API for code compilation

The API replaces 'KotlinCompilerIde' in the IntelliJ IDEA plugin.
Code moved to Analysis API as its K2 implementation severely depends on
the internal compiler API (FIR).

The API is going to be used in the JVM debugger evaluator, and in
the Bytecode Tool Window.

In this commit, only ordinary Kotlin are supported.
In later commits, there will be also support for 'KtCodeFragment' files,
as well as some test coverage.
This commit is contained in:
Yan Zhulanow
2023-07-05 22:45:54 +09:00
committed by Space Team
parent 441735c2a8
commit 0f6f22d76b
29 changed files with 1103 additions and 4 deletions
@@ -9,6 +9,7 @@ dependencies {
api(project(":analysis:analysis-api-impl-barebone"))
api(project(":analysis:kt-references"))
api(project(":compiler:resolution.common.jvm"))
implementation(project(":compiler:backend-common"))
api(intellijCore())
implementation(project(":analysis:analysis-internal-utils"))
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.analysis.api.impl.base.util
import org.jetbrains.kotlin.analysis.api.components.KtCompiledFile
import org.jetbrains.kotlin.backend.common.output.OutputFile
import java.io.File
class KtCompiledFileForOutputFile(private val outputFile: OutputFile) : KtCompiledFile {
override val path: String
get() = outputFile.relativePath
override val sourceFiles: List<File>
get() = outputFile.sourceFiles
override val content: ByteArray
get() = outputFile.asByteArray()
}