Update daemon client with wrappers for basic compiler API

Other changes to extract results for compiler, tests.

Original commit: ec7e8873f4
This commit is contained in:
Ilya Chernikov
2017-01-16 16:49:30 +01:00
parent b7f15b7777
commit 718b0c228e
@@ -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)
}
}