Skip to content

Commit 5fb1f66

Browse files
committed
Changes for pull request comments
1 parent 073b087 commit 5fb1f66

File tree

13 files changed

+97
-41
lines changed

13 files changed

+97
-41
lines changed

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ dependencies {
4949
implementation(libs.kotlin.reflect)
5050
implementation(libs.bundles.kotlin.stdlib)
5151
implementation(libs.kotlin.script.runtime)
52+
implementation(libs.kotlin.build.tools.api)
53+
implementation(libs.kotlin.build.tools.impl)
54+
implementation(libs.kotlin.compiler.embeddable)
55+
implementation(libs.kotlin.tooling.core)
5256
implementation(project(":executors", configuration = "default"))
5357
implementation(project(":common", configuration = "default"))
5458
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()}")
5959

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

common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ plugins {
33
}
44

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

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ kotlin-stdlib-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-js",
2727
kotlin-stdlib-wasm-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-wasm-js", version.ref = "kotlin" }
2828
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin" }
2929
kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin" }
30-
kotlin-compiler = { group = "org.jetbrains.kotlin", name = "kotlin-compiler", version.ref = "kotlin" }
30+
kotlin-build-tools-api = { group = "org.jetbrains.kotlin", name = "kotlin-build-tools-api", version.ref = "kotlin"}
31+
kotlin-build-tools-impl = { group = "org.jetbrains.kotlin", name = "kotlin-build-tools-impl", version.ref = "kotlin"}
32+
kotlin-compiler-embeddable = { group = "org.jetbrains.kotlin", name = "kotlin-compiler-embeddable", version.ref = "kotlin" }
3133
kotlin-tooling-core = { group = "org.jetbrains.kotlin", name = "kotlin-tooling-core", version.ref = "kotlin" }
3234
kotlin-compiler-arguments-description = { group = "org.jetbrains.kotlin", name = "kotlin-compiler-arguments-description", version.ref = "kotlin" }
3335
kotlin-script-runtime = { group = "org.jetbrains.kotlin", name = "kotlin-script-runtime", version.ref = "kotlin" }

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.

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,38 @@ import com.compiler.server.model.ProjectSeveriry
55
import com.compiler.server.model.TextInterval
66
import org.jetbrains.kotlin.buildtools.api.KotlinLogger
77

8+
9+
/**
10+
* CompilationLogger is used for collecting logs from compilation with kotlin-build-tools-api.
11+
* It is passed as an argument while executing a compilation operation. It collects logs returned
12+
* during compilation, interprets returned strings, and saves logs in the map based on their severity.
13+
* The map is later used to provide information about warnings and errors in the user's code.
14+
*
15+
* KotlinLogger interface will be changed in the future to contain more log details.
16+
* Implementation of the CompilationLogger should be therefore updated after KT-80963 is implemented.
17+
*
18+
* @property isDebugEnabled A flag to indicate whether debug-level logging is enabled for the logger.
19+
* If true, all messages are printed to the standard output.
20+
*/
821
class CompilationLogger(
922
override val isDebugEnabled: Boolean = false,
1023
) : KotlinLogger {
1124

25+
/**
26+
* Stores a collection of compilation logs organized by file paths.
27+
*
28+
* The map keys represent file paths as strings, and the associated values are mutable lists of
29+
* `ErrorDescriptor` objects containing details about compilation issues, such as error messages,
30+
* intervals, severity, and optional class names.
31+
*/
1232
var compilationLogs: Map<String, MutableList<ErrorDescriptor>> = emptyMap()
1333

1434
override fun debug(msg: String) {
1535
if (isDebugEnabled) println("[DEBUG] $msg")
1636
}
1737

1838
override fun error(msg: String, throwable: Throwable?) {
19-
if (isDebugEnabled) System.err.println("[ERROR] $msg" + (throwable?.let { ": ${it.message}" } ?: ""))
39+
if (isDebugEnabled) println("[ERROR] $msg" + (throwable?.let { ": ${it.message}" } ?: ""))
2040
try {
2141
addCompilationLog(msg, ProjectSeveriry.ERROR, classNameOverride = null)
2242
} catch (_: Exception) {}
@@ -31,12 +51,22 @@ class CompilationLogger(
3151
}
3252

3353
override fun warn(msg: String, throwable: Throwable?) {
34-
if (isDebugEnabled) System.err.println("[WARN] $msg" + (throwable?.let { ": ${it.message}" } ?: ""))
54+
if (isDebugEnabled) println("[WARN] $msg" + (throwable?.let { ": ${it.message}" } ?: ""))
3555
try {
3656
addCompilationLog(msg, ProjectSeveriry.WARNING, classNameOverride = "WARNING")
3757
} catch (_: Exception) {}
3858
}
3959

60+
61+
/**
62+
* Adds a compilation log entry to the `compilationLogs` map based on the sting log.
63+
*
64+
* @param msg The raw log message containing information about the compilation event,
65+
* including the file path and error details.
66+
* @param severity The severity level of the compilation event, represented by the `ProjectSeveriry` enum.
67+
* @param classNameOverride An optional override for the class name that will be recorded in the log.
68+
* If null, it will be derived from the file path in the message.
69+
*/
4070
private fun addCompilationLog(msg: String, severity: ProjectSeveriry, classNameOverride: String?) {
4171
val path = msg.split(" ")[0]
4272
val className = path.split("/").last().split(".").first()

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

Whitespace-only changes.

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

Whitespace-only changes.

0 commit comments

Comments
 (0)