Minor: introduce EXCEPTION report category

This commit is contained in:
Alexey Tsvetkov
2017-01-13 08:24:23 +03:00
parent c2a125ff1c
commit 072edf4b5a
5 changed files with 59 additions and 42 deletions
@@ -32,9 +32,10 @@ interface CompilerServicesFacadeBase : Remote {
enum class ReportCategory(val code: Int) {
COMPILER_MESSAGE(0),
DAEMON_MESSAGE(1),
IC_MESSAGE(2),
OUTPUT_MESSAGE(3);
EXCEPTION(1),
DAEMON_MESSAGE(2),
IC_MESSAGE(3),
OUTPUT_MESSAGE(4);
companion object {
fun fromCode(code: Int): ReportCategory? =
@@ -58,12 +59,3 @@ enum class ReportSeverity(val code: Int) {
fun CompilerServicesFacadeBase.report(category: ReportCategory, severity: ReportSeverity, message: String? = null, attachment: Serializable? = null) {
report(category.code, severity.code, message, attachment)
}
data class CompilerMessageAttachment(
val severity: CompilerMessageSeverity,
val location: CompilerMessageLocation
) : Serializable {
companion object {
const val serialVersionUID = 0L
}
}
@@ -33,25 +33,28 @@ internal class CompileServicesFacadeMessageCollector(
}
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) {
val reportCategory = when (severity) {
CompilerMessageSeverity.OUTPUT -> ReportCategory.OUTPUT_MESSAGE
else -> ReportCategory.COMPILER_MESSAGE
when (severity) {
CompilerMessageSeverity.OUTPUT -> {
servicesFacade.report(ReportCategory.OUTPUT_MESSAGE, ReportSeverity.ERROR, message)
}
CompilerMessageSeverity.EXCEPTION -> {
servicesFacade.report(ReportCategory.EXCEPTION, ReportSeverity.ERROR, message)
}
else -> {
val reportSeverity = when (severity) {
CompilerMessageSeverity.ERROR -> ReportSeverity.ERROR
CompilerMessageSeverity.WARNING -> ReportSeverity.WARNING
CompilerMessageSeverity.INFO -> ReportSeverity.INFO
else -> ReportSeverity.DEBUG
}
if (reportSeverity.code <= mySeverity) {
servicesFacade.report(ReportCategory.COMPILER_MESSAGE, reportSeverity, message, location)
}
}
}
val reportSeverity = when (severity) {
CompilerMessageSeverity.ERROR,
CompilerMessageSeverity.EXCEPTION -> ReportSeverity.ERROR
CompilerMessageSeverity.WARNING -> ReportSeverity.WARNING
CompilerMessageSeverity.INFO -> ReportSeverity.INFO
CompilerMessageSeverity.LOGGING -> ReportSeverity.DEBUG
CompilerMessageSeverity.OUTPUT -> ReportSeverity.ERROR
}
if (reportSeverity.code <= mySeverity) {
servicesFacade.report(reportCategory, reportSeverity, message, CompilerMessageAttachment(severity, location))
}
hasErrors = hasErrors || severity == CompilerMessageSeverity.ERROR
hasErrors = hasErrors || severity == CompilerMessageSeverity.ERROR || severity == CompilerMessageSeverity.EXCEPTION
}
override fun hasErrors(): Boolean = hasErrors