Skip to content

Commit 073b087

Browse files
committed
KTL-2962 Compilation with BTA for JVM
1 parent bf4129f commit 073b087

File tree

18 files changed

+128
-28
lines changed

18 files changed

+128
-28
lines changed

build.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,18 @@ dependencies {
4444
implementation(libs.gson)
4545
implementation(libs.kotlinx.serialization.json)
4646
implementation(libs.kotlin.compiler.arguments.description)
47-
implementation(libs.kotlin.tooling.core)
4847
implementation(libs.junit)
4948
implementation(libs.logback.logstash.encoder)
5049
implementation(libs.kotlin.reflect)
51-
implementation(libs.kotlin.stdlib)
52-
implementation(libs.kotlin.compiler)
50+
implementation(libs.bundles.kotlin.stdlib)
5351
implementation(libs.kotlin.script.runtime)
5452
implementation(project(":executors", configuration = "default"))
5553
implementation(project(":common", configuration = "default"))
5654
implementation(project(":dependencies"))
55+
implementation("org.jetbrains.kotlin:kotlin-build-tools-api:${libs.versions.kotlin.get()}")
56+
implementation("org.jetbrains.kotlin:kotlin-build-tools-impl:${libs.versions.kotlin.get()}")
57+
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${libs.versions.kotlin.get()}")
58+
implementation("org.jetbrains.kotlin:kotlin-tooling-core:${libs.versions.kotlin.get()}")
5759

5860
testImplementation(libs.kotlin.test)
5961
testImplementation("org.springframework.boot:spring-boot-starter-test") {

common/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ plugins {
33
}
44

55
dependencies {
6-
implementation(libs.kotlin.compiler)
7-
}
6+
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${libs.versions.kotlin.get()}")
7+
}

dependencies/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ dependencies {
103103
kotlinDependency(libs.hamcrest)
104104
kotlinDependency(libs.bundles.jackson)
105105
// Kotlin libraries
106-
kotlinDependency(libs.kotlin.stdlib)
106+
kotlinDependency(libs.bundles.kotlin.stdlib)
107107
kotlinDependency(libs.kotlin.test)
108108
kotlinDependency(libs.kotlin.test.junit)
109109
kotlinDependency(libs.kotlinx.coroutines.core.jvm)

gradle/libs.versions.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
kotlin = "2.3.0-dev-9317"
2+
kotlin = "2.3.0-dev-9673"
33
spring-boot = "3.5.6"
44
spring-dependency-managment = "1.1.7"
55
springdoc = "2.8.13"
@@ -21,6 +21,8 @@ gradle-develocity = "3.17.5"
2121
[libraries]
2222
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
2323
kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
24+
kotlin-stdlib-jdk7 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk7", version.ref = "kotlin" }
25+
kotlin-stdlib-jdk8 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" }
2426
kotlin-stdlib-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-js", version.ref = "kotlin" }
2527
kotlin-stdlib-wasm-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-wasm-js", version.ref = "kotlin" }
2628
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin" }
@@ -66,6 +68,7 @@ spring-context-indexer = { group = "org.springframework", name = "spring-context
6668
springdoc = { group = "org.springdoc", name = "springdoc-openapi-starter-webmvc-ui", version.ref = "springdoc" }
6769

6870
[bundles]
71+
kotlin-stdlib = ["kotlin-stdlib", "kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8"]
6972
jackson = ["jackson-databind", "jackson-core", "jackson-annotations"]
7073
compose = [
7174
"compose-runtime",

indexation/build.gradle.kts

Whitespace-only changes.

indexation/src/main/kotlin/DescriptorsUtils.kt

Whitespace-only changes.

src/main/kotlin/com/compiler/server/compiler/KotlinFile.kt

Whitespace-only changes.

src/main/kotlin/com/compiler/server/compiler/KotlinResolutionFacade.kt

Whitespace-only changes.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.compiler.server.compiler.components
2+
3+
import com.compiler.server.model.ErrorDescriptor
4+
import com.compiler.server.model.ProjectSeveriry
5+
import com.compiler.server.model.TextInterval
6+
import org.jetbrains.kotlin.buildtools.api.KotlinLogger
7+
8+
class CompilationLogger(
9+
override val isDebugEnabled: Boolean = false,
10+
) : KotlinLogger {
11+
12+
var compilationLogs: Map<String, MutableList<ErrorDescriptor>> = emptyMap()
13+
14+
override fun debug(msg: String) {
15+
if (isDebugEnabled) println("[DEBUG] $msg")
16+
}
17+
18+
override fun error(msg: String, throwable: Throwable?) {
19+
if (isDebugEnabled) System.err.println("[ERROR] $msg" + (throwable?.let { ": ${it.message}" } ?: ""))
20+
try {
21+
addCompilationLog(msg, ProjectSeveriry.ERROR, classNameOverride = null)
22+
} catch (_: Exception) {}
23+
}
24+
25+
override fun info(msg: String) {
26+
if (isDebugEnabled) println("[INFO] $msg")
27+
}
28+
29+
override fun lifecycle(msg: String) {
30+
if (isDebugEnabled) println("[LIFECYCLE] $msg")
31+
}
32+
33+
override fun warn(msg: String, throwable: Throwable?) {
34+
if (isDebugEnabled) System.err.println("[WARN] $msg" + (throwable?.let { ": ${it.message}" } ?: ""))
35+
try {
36+
addCompilationLog(msg, ProjectSeveriry.WARNING, classNameOverride = "WARNING")
37+
} catch (_: Exception) {}
38+
}
39+
40+
private fun addCompilationLog(msg: String, severity: ProjectSeveriry, classNameOverride: String?) {
41+
val path = msg.split(" ")[0]
42+
val className = path.split("/").last().split(".").first()
43+
val message = msg.split(path)[1].drop(1)
44+
val splitPath = path.split(":")
45+
val line = splitPath[splitPath.size - 4].toInt() - 1
46+
val ch = splitPath[splitPath.size - 3].toInt() - 1
47+
val endLine = splitPath[splitPath.size - 2].toInt() - 1
48+
val endCh = splitPath[splitPath.size - 1].toInt() - 1
49+
val ed = ErrorDescriptor(
50+
TextInterval(TextInterval.TextPosition(line, ch), TextInterval.TextPosition(endLine, endCh)),
51+
message,
52+
severity,
53+
classNameOverride ?: className
54+
)
55+
compilationLogs["$className.kt"]?.add(ed)
56+
}
57+
}

src/main/kotlin/com/compiler/server/compiler/components/CompletionProvider.kt

Whitespace-only changes.

0 commit comments

Comments
 (0)