Use null instead of CompilerMessageLocation.NO_LOCATION in MessageCollector
This commit is contained in:
+6
-11
@@ -20,21 +20,17 @@ import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.util.containers.Stack
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil.reportException
|
||||
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil
|
||||
import org.xml.sax.Attributes
|
||||
import org.xml.sax.InputSource
|
||||
import org.xml.sax.SAXException
|
||||
import org.xml.sax.helpers.DefaultHandler
|
||||
|
||||
import javax.xml.parsers.SAXParser
|
||||
import javax.xml.parsers.SAXParserFactory
|
||||
import java.io.IOException
|
||||
import java.io.Reader
|
||||
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation.Companion.NO_LOCATION
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil.reportException
|
||||
import javax.xml.parsers.SAXParserFactory
|
||||
|
||||
object CompilerOutputParser {
|
||||
fun parseCompilerMessagesFromReader(messageCollector: MessageCollector, reader: Reader, collector: OutputItemsCollector) {
|
||||
@@ -77,7 +73,7 @@ object CompilerOutputParser {
|
||||
|
||||
val message = stringBuilder.toString()
|
||||
reportException(messageCollector, IllegalStateException(message, e))
|
||||
messageCollector.report(ERROR, message, NO_LOCATION)
|
||||
messageCollector.report(ERROR, message)
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
@@ -86,7 +82,6 @@ object CompilerOutputParser {
|
||||
catch (e: IOException) {
|
||||
reportException(messageCollector, e)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +110,7 @@ object CompilerOutputParser {
|
||||
// We're directly inside the root tag: <MESSAGES>
|
||||
val message = String(ch!!, start, length)
|
||||
if (!message.trim { it <= ' ' }.isEmpty()) {
|
||||
messageCollector.report(ERROR, "Unhandled compiler output: " + message, NO_LOCATION)
|
||||
messageCollector.report(ERROR, "Unhandled compiler output: $message")
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -132,7 +127,7 @@ object CompilerOutputParser {
|
||||
val qNameLowerCase = qName.toLowerCase()
|
||||
var category: CompilerMessageSeverity? = CATEGORIES[qNameLowerCase]
|
||||
if (category == null) {
|
||||
messageCollector.report(ERROR, "Unknown compiler message tag: " + qName, NO_LOCATION)
|
||||
messageCollector.report(ERROR, "Unknown compiler message tag: $qName")
|
||||
category = INFO
|
||||
}
|
||||
val text = message.toString()
|
||||
|
||||
+3
-10
@@ -18,19 +18,14 @@ package org.jetbrains.kotlin.compilerRunner
|
||||
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil
|
||||
import org.jetbrains.kotlin.daemon.client.CompileServiceSession
|
||||
import org.jetbrains.kotlin.daemon.client.CompilationServices
|
||||
import org.jetbrains.kotlin.daemon.client.DaemonReportMessage
|
||||
import org.jetbrains.kotlin.daemon.client.DaemonReportingTargets
|
||||
import org.jetbrains.kotlin.daemon.client.KotlinCompilerClient
|
||||
import org.jetbrains.kotlin.daemon.common.*
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
||||
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
||||
import java.io.BufferedReader
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
@@ -90,7 +85,7 @@ abstract class KotlinCompilerRunner<in Env : CompilerEnvironment> {
|
||||
DaemonReportCategory.INFO -> CompilerMessageSeverity.INFO
|
||||
DaemonReportCategory.EXCEPTION -> CompilerMessageSeverity.EXCEPTION
|
||||
}
|
||||
environment.messageCollector.report(severity, message.message, CompilerMessageLocation.NO_LOCATION)
|
||||
environment.messageCollector.report(severity, message.message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,9 +93,7 @@ abstract class KotlinCompilerRunner<in Env : CompilerEnvironment> {
|
||||
if (daemonOptions.reportPerf) {
|
||||
fun Long.ms() = TimeUnit.NANOSECONDS.toMillis(this)
|
||||
val counters = profiler.getTotalCounters()
|
||||
messageCollector.report(CompilerMessageSeverity.INFO,
|
||||
"PERF: $message ${counters.time.ms()} ms, thread ${counters.threadTime.ms()}",
|
||||
CompilerMessageLocation.NO_LOCATION)
|
||||
messageCollector.report(CompilerMessageSeverity.INFO, "PERF: $message ${counters.time.ms()} ms, thread ${counters.threadTime.ms()}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +115,7 @@ abstract class KotlinCompilerRunner<in Env : CompilerEnvironment> {
|
||||
}
|
||||
|
||||
protected fun reportInternalCompilerError(messageCollector: MessageCollector): ExitCode {
|
||||
messageCollector.report(ERROR, "Compiler terminated with internal error", CompilerMessageLocation.NO_LOCATION)
|
||||
messageCollector.report(CompilerMessageSeverity.ERROR, "Compiler terminated with internal error")
|
||||
return ExitCode.INTERNAL_ERROR
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user