From 718b0c228e147c37f0d0bb2ac41e0fba55cb9866 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Mon, 16 Jan 2017 16:49:30 +0100 Subject: [PATCH] Update daemon client with wrappers for basic compiler API Other changes to extract results for compiler, tests. Original commit: ec7e8873f4e09304b47978f974f3c537c38fc96b --- .../JpsCompilerServicesFacadeImpl.kt | 63 ++----------------- 1 file changed, 6 insertions(+), 57 deletions(-) diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerServicesFacadeImpl.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerServicesFacadeImpl.kt index 285677acf08..3410543678a 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerServicesFacadeImpl.kt +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerServicesFacadeImpl.kt @@ -16,11 +16,10 @@ package org.jetbrains.kotlin.compilerRunner -import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation -import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity -import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil import org.jetbrains.kotlin.daemon.client.CompilerCallbackServicesFacadeServer -import org.jetbrains.kotlin.daemon.common.* +import org.jetbrains.kotlin.daemon.client.reportFromDaemon +import org.jetbrains.kotlin.daemon.common.JpsCompilerServicesFacade +import org.jetbrains.kotlin.daemon.common.SOCKET_ANY_FREE_PORT import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents import org.jetbrains.kotlin.progress.CompilationCanceledStatus import java.io.Serializable @@ -34,58 +33,8 @@ internal class JpsCompilerServicesFacadeImpl( JpsCompilerServicesFacade { override fun report(category: Int, severity: Int, message: String?, attachment: Serializable?) { - val reportCategory = ReportCategory.fromCode(category) - - when (reportCategory) { - ReportCategory.OUTPUT_MESSAGE -> { - val output = OutputMessageUtil.parseOutputMessage(message!!) - if (output != null) { - env.outputItemsCollector.add(output.sourceFiles, output.outputFile) - } - } - ReportCategory.EXCEPTION -> { - env.messageCollector.report(CompilerMessageSeverity.EXCEPTION, message!!, CompilerMessageLocation.NO_LOCATION) - } - ReportCategory.COMPILER_MESSAGE -> { - val compilerSeverity = when (ReportSeverity.fromCode(severity)) { - ReportSeverity.ERROR -> CompilerMessageSeverity.ERROR - ReportSeverity.WARNING -> CompilerMessageSeverity.WARNING - ReportSeverity.INFO -> CompilerMessageSeverity.INFO - ReportSeverity.DEBUG -> CompilerMessageSeverity.LOGGING - else -> throw IllegalStateException("Unexpected compiler message report severity $severity") - } - if (message != null && attachment is CompilerMessageLocation) { - env.messageCollector.report(compilerSeverity, message, attachment) - } - else { - reportUnexpected(category, severity, message, attachment) - } - } - ReportCategory.DAEMON_MESSAGE, - ReportCategory.IC_MESSAGE -> { - if (message != null) { - env.messageCollector.report(CompilerMessageSeverity.LOGGING, message, CompilerMessageLocation.NO_LOCATION) - } - else { - reportUnexpected(category, severity, message, attachment) - } - } - else -> { - reportUnexpected(category, severity, message, attachment) - } - } - } - - private fun reportUnexpected(category: Int, severity: Int, message: String?, attachment: Serializable?) { - val compilerMessageSeverity = when (ReportSeverity.fromCode(severity)) { - ReportSeverity.ERROR -> CompilerMessageSeverity.ERROR - ReportSeverity.WARNING -> CompilerMessageSeverity.WARNING - ReportSeverity.INFO -> CompilerMessageSeverity.INFO - else -> CompilerMessageSeverity.LOGGING - } - - env.messageCollector.report(compilerMessageSeverity, - "Unexpected message: category=$category; severity=$severity; message='$message'; attachment=$attachment", - CompilerMessageLocation.NO_LOCATION) + env.messageCollector.reportFromDaemon( + { outFile, srcFiles -> env.outputItemsCollector.add(srcFiles, outFile) }, + category, severity, message, attachment) } } \ No newline at end of file