diff --git a/jps/jps-plugin/jps-plugin.iml b/jps/jps-plugin/jps-plugin.iml index 21a11f39ee9..59e6dad560b 100644 --- a/jps/jps-plugin/jps-plugin.iml +++ b/jps/jps-plugin/jps-plugin.iml @@ -20,5 +20,6 @@ + \ No newline at end of file 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 71b8337a3fc..b4df5aa4089 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerServicesFacadeImpl.kt +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsCompilerServicesFacadeImpl.kt @@ -19,9 +19,7 @@ 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.daemon.client.CompilerCallbackServicesFacadeServer -import org.jetbrains.kotlin.daemon.common.JpsCompilerServicesFacade -import org.jetbrains.kotlin.daemon.common.ReportCategory -import org.jetbrains.kotlin.daemon.common.SOCKET_ANY_FREE_PORT +import org.jetbrains.kotlin.daemon.common.* import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents import org.jetbrains.kotlin.progress.CompilationCanceledStatus import java.io.Serializable @@ -34,20 +32,26 @@ internal class JpsCompilerServicesFacadeImpl( port), JpsCompilerServicesFacade { - override fun report(category: ReportCategory, severity: Int, message: String?, attachment: Serializable?) { - when (category) { + override fun report(category: Int, severity: Int, message: String?, attachment: Serializable?) { + val reportCategory = ReportCategory.fromCode(category) + + when (reportCategory) { + ReportCategory.OUTPUT_MESSAGE -> { + env.messageCollector.report(CompilerMessageSeverity.OUTPUT, message!!, CompilerMessageLocation.NO_LOCATION) + } ReportCategory.COMPILER_MESSAGE -> { - val compilerMessageSeverity = CompilerMessageSeverity.values().firstOrNull { it.value == severity } - if (compilerMessageSeverity != null) { - val location = attachment as? CompilerMessageLocation ?: CompilerMessageLocation.NO_LOCATION - env.messageCollector.report(compilerMessageSeverity, message!!, location) + val compilerMessageAttachment = attachment as? CompilerMessageAttachment + if (message != null && compilerMessageAttachment != null) { + val originalSeverity = compilerMessageAttachment.severity + val originalLocation = compilerMessageAttachment.location + env.messageCollector.report(originalSeverity, message, originalLocation) } else { reportUnexpected(category, severity, message, attachment) } } ReportCategory.DAEMON_MESSAGE, - ReportCategory.INCREMENTAL_COMPILATION -> { + ReportCategory.IC_MESSAGE -> { if (message != null) { env.messageCollector.report(CompilerMessageSeverity.LOGGING, message, CompilerMessageLocation.NO_LOCATION) } @@ -61,8 +65,15 @@ internal class JpsCompilerServicesFacadeImpl( } } - private fun reportUnexpected(category: ReportCategory, severity: Int, message: String?, attachment: Serializable?) { - env.messageCollector.report(CompilerMessageSeverity.LOGGING, + 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) } diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt index 2a99aad5190..75c670d28e4 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt @@ -28,6 +28,8 @@ import org.jetbrains.kotlin.jps.build.KotlinBuilder import java.io.ByteArrayOutputStream import java.io.File import java.io.PrintStream +import java.io.Serializable +import java.rmi.server.UnicastRemoteObject import java.util.* class JpsKotlinCompilerRunner : KotlinCompilerRunner() { @@ -99,39 +101,30 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner() { } val res = withDaemon(environment, retryOnConnectionError = true) { daemon, sessionId -> - val options = CompilationOptions(CompileService.CompilerMode.JPS_COMPILER, - targetPlatform, - reportingFilters = getReportingFilters(compilerArgs.verbose)) - daemon.compile(sessionId, compilerArgs, options, JpsCompilerServicesFacadeImpl(environment)) + val compilerMode = CompileService.CompilerMode.JPS_COMPILER + val verbose = compilerArgs.verbose + val options = CompilationOptions(compilerMode, targetPlatform, reportCategories(verbose), reportSeverity(verbose), requestedCompilationResults = emptyArray()) + daemon.compile(sessionId, compilerArgs, options, JpsCompilerServicesFacadeImpl(environment), null) } return res?.get()?.let { exitCodeFromProcessExitCode(it) } } - private fun getReportingFilters(verbose: Boolean): List { - val result = ArrayList() - - val compilerMessagesSeverities = ArrayList().apply { - add(CompilerMessageSeverity.ERROR.value) - add(CompilerMessageSeverity.EXCEPTION.value) - add(CompilerMessageSeverity.WARNING.value) - add(CompilerMessageSeverity.INFO.value) - add(CompilerMessageSeverity.OUTPUT.value) - - if (verbose) { - add(CompilerMessageSeverity.LOGGING.value) + private fun reportCategories(verbose: Boolean): Array = + if (!verbose) { + arrayOf(ReportCategory.COMPILER_MESSAGE.code) + } + else { + ReportCategory.values().map { it.code }.toTypedArray() } - } - if (verbose) { - result.add(ReportingFilter(ReportCategory.DAEMON_MESSAGE, emptyList())) - } - - val compilerMessagesFilter = ReportingFilter(ReportCategory.COMPILER_MESSAGE, compilerMessagesSeverities) - result.add(compilerMessagesFilter) - - return result - } + private fun reportSeverity(verbose: Boolean): Int = + if (!verbose) { + ReportSeverity.INFO.code + } + else { + ReportSeverity.DEBUG.code + } private fun fallbackCompileStrategy( argsArray: Array,