Minor: introduce EXCEPTION report category
This commit is contained in:
+4
-12
@@ -32,9 +32,10 @@ interface CompilerServicesFacadeBase : Remote {
|
|||||||
|
|
||||||
enum class ReportCategory(val code: Int) {
|
enum class ReportCategory(val code: Int) {
|
||||||
COMPILER_MESSAGE(0),
|
COMPILER_MESSAGE(0),
|
||||||
DAEMON_MESSAGE(1),
|
EXCEPTION(1),
|
||||||
IC_MESSAGE(2),
|
DAEMON_MESSAGE(2),
|
||||||
OUTPUT_MESSAGE(3);
|
IC_MESSAGE(3),
|
||||||
|
OUTPUT_MESSAGE(4);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromCode(code: Int): ReportCategory? =
|
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) {
|
fun CompilerServicesFacadeBase.report(category: ReportCategory, severity: ReportSeverity, message: String? = null, attachment: Serializable? = null) {
|
||||||
report(category.code, severity.code, message, attachment)
|
report(category.code, severity.code, message, attachment)
|
||||||
}
|
}
|
||||||
|
|
||||||
data class CompilerMessageAttachment(
|
|
||||||
val severity: CompilerMessageSeverity,
|
|
||||||
val location: CompilerMessageLocation
|
|
||||||
) : Serializable {
|
|
||||||
companion object {
|
|
||||||
const val serialVersionUID = 0L
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+20
-17
@@ -33,25 +33,28 @@ internal class CompileServicesFacadeMessageCollector(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) {
|
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) {
|
||||||
val reportCategory = when (severity) {
|
when (severity) {
|
||||||
CompilerMessageSeverity.OUTPUT -> ReportCategory.OUTPUT_MESSAGE
|
CompilerMessageSeverity.OUTPUT -> {
|
||||||
else -> ReportCategory.COMPILER_MESSAGE
|
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) {
|
hasErrors = hasErrors || severity == CompilerMessageSeverity.ERROR || severity == CompilerMessageSeverity.EXCEPTION
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hasErrors(): Boolean = hasErrors
|
override fun hasErrors(): Boolean = hasErrors
|
||||||
|
|||||||
+12
-5
@@ -39,12 +39,19 @@ internal class JpsCompilerServicesFacadeImpl(
|
|||||||
ReportCategory.OUTPUT_MESSAGE -> {
|
ReportCategory.OUTPUT_MESSAGE -> {
|
||||||
env.messageCollector.report(CompilerMessageSeverity.OUTPUT, message!!, CompilerMessageLocation.NO_LOCATION)
|
env.messageCollector.report(CompilerMessageSeverity.OUTPUT, message!!, CompilerMessageLocation.NO_LOCATION)
|
||||||
}
|
}
|
||||||
|
ReportCategory.EXCEPTION -> {
|
||||||
|
env.messageCollector.report(CompilerMessageSeverity.EXCEPTION, message!!, CompilerMessageLocation.NO_LOCATION)
|
||||||
|
}
|
||||||
ReportCategory.COMPILER_MESSAGE -> {
|
ReportCategory.COMPILER_MESSAGE -> {
|
||||||
val compilerMessageAttachment = attachment as? CompilerMessageAttachment
|
val compilerSeverity = when (ReportSeverity.fromCode(severity)) {
|
||||||
if (message != null && compilerMessageAttachment != null) {
|
ReportSeverity.ERROR -> CompilerMessageSeverity.ERROR
|
||||||
val originalSeverity = compilerMessageAttachment.severity
|
ReportSeverity.WARNING -> CompilerMessageSeverity.WARNING
|
||||||
val originalLocation = compilerMessageAttachment.location
|
ReportSeverity.INFO -> CompilerMessageSeverity.INFO
|
||||||
env.messageCollector.report(originalSeverity, message, originalLocation)
|
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 {
|
else {
|
||||||
reportUnexpected(category, severity, message, attachment)
|
reportUnexpected(category, severity, message, attachment)
|
||||||
|
|||||||
@@ -110,14 +110,19 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
return res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
return res?.get()?.let { exitCodeFromProcessExitCode(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reportCategories(verbose: Boolean): Array<Int> =
|
private fun reportCategories(verbose: Boolean): Array<Int> {
|
||||||
|
val categories =
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
arrayOf(ReportCategory.COMPILER_MESSAGE.code)
|
arrayOf(ReportCategory.COMPILER_MESSAGE, ReportCategory.EXCEPTION)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ReportCategory.values().map { it.code }.toTypedArray()
|
ReportCategory.values()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return categories.map { it.code }.toTypedArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun reportSeverity(verbose: Boolean): Int =
|
private fun reportSeverity(verbose: Boolean): Int =
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
ReportSeverity.INFO.code
|
ReportSeverity.INFO.code
|
||||||
|
|||||||
+15
-5
@@ -29,9 +29,22 @@ internal open class GradleCompilerServicesFacadeImpl(
|
|||||||
val reportCategory = ReportCategory.fromCode(category)
|
val reportCategory = ReportCategory.fromCode(category)
|
||||||
|
|
||||||
when (reportCategory) {
|
when (reportCategory) {
|
||||||
|
ReportCategory.OUTPUT_MESSAGE -> {
|
||||||
|
compilerMessageCollector.report(CompilerMessageSeverity.OUTPUT, message!!, CompilerMessageLocation.NO_LOCATION)
|
||||||
|
}
|
||||||
|
ReportCategory.EXCEPTION -> {
|
||||||
|
compilerMessageCollector.report(CompilerMessageSeverity.EXCEPTION, message!!, CompilerMessageLocation.NO_LOCATION)
|
||||||
|
}
|
||||||
ReportCategory.COMPILER_MESSAGE -> {
|
ReportCategory.COMPILER_MESSAGE -> {
|
||||||
if (message != null && attachment is CompilerMessageAttachment) {
|
val compilerSeverity = when (ReportSeverity.fromCode(severity)) {
|
||||||
compilerMessageCollector.report(attachment.severity, message, attachment.location)
|
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) {
|
||||||
|
compilerMessageCollector.report(compilerSeverity, message, attachment)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
reportUnexpectedMessage(category, severity, message, attachment)
|
reportUnexpectedMessage(category, severity, message, attachment)
|
||||||
@@ -43,9 +56,6 @@ internal open class GradleCompilerServicesFacadeImpl(
|
|||||||
ReportCategory.DAEMON_MESSAGE -> {
|
ReportCategory.DAEMON_MESSAGE -> {
|
||||||
log.kotlinDebug { "[DAEMON] $message" }
|
log.kotlinDebug { "[DAEMON] $message" }
|
||||||
}
|
}
|
||||||
ReportCategory.OUTPUT_MESSAGE -> {
|
|
||||||
compilerMessageCollector.report(CompilerMessageSeverity.OUTPUT, message!!, CompilerMessageLocation.NO_LOCATION)
|
|
||||||
}
|
|
||||||
else -> {
|
else -> {
|
||||||
reportUnexpectedMessage(category, severity, message, attachment)
|
reportUnexpectedMessage(category, severity, message, attachment)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user