From e85862e20cc0a442d63cf4b6debb144a7821225c Mon Sep 17 00:00:00 2001 From: Stanislav Ruban Date: Wed, 12 Feb 2025 11:28:47 +0200 Subject: [PATCH] [build scripts] Preserve source information in all compiler messages instead of just errors This change leads to logging more detailed compiler warnings during IJ monorepo compilation. The Kotlin team requires this information to more accurately estimate impact of breaking language changes. KQA-1867 GitOrigin-RevId: 98949b521c1c0d3f8fe9bf020c5ab2d6ad02038e --- .../impl/logging/jps/JpsLoggerFactory.kt | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/logging/jps/JpsLoggerFactory.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/logging/jps/JpsLoggerFactory.kt index c68b220f7220..42042b066113 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/logging/jps/JpsLoggerFactory.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/logging/jps/JpsLoggerFactory.kt @@ -88,34 +88,11 @@ internal class JpsMessageHandler(private val context: CompilationContext, privat private var progress = -1.0f override fun processMessage(message: BuildMessage): Unit = TeamCityBuildMessageLogger.withFlow(span) { - val text = message.messageText + val text = if (message is CompilerMessage) message.compilerMessageText else message.messageText when (message.kind) { BuildMessage.Kind.ERROR, BuildMessage.Kind.INTERNAL_BUILDER_ERROR -> { - val compilerName: String - val messageText: String - if (message is CompilerMessage) { - compilerName = message.compilerName - val sourcePath = message.sourcePath - messageText = buildString { - if (sourcePath != null) { - append(sourcePath) - if (message.line != -1L) { - append(':').append(message.line) - } - appendLine(':') - } - append(text) - val moduleNames = message.moduleNames - if (moduleNames.any()) { - append(moduleNames.joinToString(prefix = " (", postfix = ")")) - } - } - } - else { - compilerName = "" - messageText = text - } - errorMessagesByCompiler.computeIfAbsent(compilerName) { CopyOnWriteArrayList() }.add(messageText) + val compilerName: String = if (message is CompilerMessage) message.compilerName else "" + errorMessagesByCompiler.computeIfAbsent(compilerName) { CopyOnWriteArrayList() }.add(text) } BuildMessage.Kind.WARNING -> context.messages.warning(text) BuildMessage.Kind.INFO, BuildMessage.Kind.JPS_INFO -> if (message is BuilderStatisticsMessage) { @@ -185,6 +162,26 @@ internal class JpsMessageHandler(private val context: CompilationContext, privat } } + private val CompilerMessage.compilerMessageText: String get() { + return buildString { + if (sourcePath != null) { + append(sourcePath) + if (line != -1L) { + append(':').append(line) + } + if (column != -1L) { + append(':').append(column) + } + appendLine(':') + } + append(messageText) + if (moduleNames.any()) { + appendLine() + append(moduleNames.joinToString(prefix = "(JPS module: ", postfix = ")")) + } + } + } + private fun reportProgress(targets: Collection>, targetSpecificMessage: String) { val targetsString = targets.joinToString(separator = ", ") { Introspector.decapitalize(it.presentableName) } val progressText = if (progress >= 0) " (${(100 * progress).toInt()}%)" else ""