Apply reformatting to CompilerOutputParser.kt
This commit is contained in:
committed by
Space Team
parent
b14406b7b7
commit
b4e8e27a6f
+17
-22
@@ -64,32 +64,29 @@ object CompilerOutputParser {
|
|||||||
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
|
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
|
||||||
val parser = factory.newSAXParser()
|
val parser = factory.newSAXParser()
|
||||||
parser.parse(InputSource(wrappingReader), CompilerOutputSAXHandler(messageCollector, collector))
|
parser.parse(InputSource(wrappingReader), CompilerOutputSAXHandler(messageCollector, collector))
|
||||||
}
|
} catch (e: Throwable) {
|
||||||
catch (e: Throwable) {
|
|
||||||
// Load all the text into the stringBuilder
|
// Load all the text into the stringBuilder
|
||||||
try {
|
try {
|
||||||
// This will not close the reader (see the wrapper above)
|
// This will not close the reader (see the wrapper above)
|
||||||
FileUtil.loadTextAndClose(wrappingReader)
|
FileUtil.loadTextAndClose(wrappingReader)
|
||||||
}
|
} catch (ioException: IOException) {
|
||||||
catch (ioException: IOException) {
|
|
||||||
reportException(messageCollector, ioException)
|
reportException(messageCollector, ioException)
|
||||||
}
|
}
|
||||||
|
|
||||||
val message = stringBuilder.toString()
|
val message = stringBuilder.toString()
|
||||||
reportException(messageCollector, IllegalStateException(message, e))
|
reportException(messageCollector, IllegalStateException(message, e))
|
||||||
messageCollector.report(ERROR, message)
|
messageCollector.report(ERROR, message)
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
try {
|
try {
|
||||||
reader.close()
|
reader.close()
|
||||||
}
|
} catch (e: IOException) {
|
||||||
catch (e: IOException) {
|
|
||||||
reportException(messageCollector, e)
|
reportException(messageCollector, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CompilerOutputSAXHandler(private val messageCollector: MessageCollector, private val collector: OutputItemsCollector) : DefaultHandler() {
|
private class CompilerOutputSAXHandler(private val messageCollector: MessageCollector, private val collector: OutputItemsCollector) :
|
||||||
|
DefaultHandler() {
|
||||||
|
|
||||||
private val message = StringBuilder()
|
private val message = StringBuilder()
|
||||||
private val tags = Stack<String>()
|
private val tags = Stack<String>()
|
||||||
@@ -116,8 +113,7 @@ object CompilerOutputParser {
|
|||||||
if (!message.trim { it <= ' ' }.isEmpty()) {
|
if (!message.trim { it <= ' ' }.isEmpty()) {
|
||||||
messageCollector.report(ERROR, "Unhandled compiler output: $message")
|
messageCollector.report(ERROR, "Unhandled compiler output: $message")
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
message.append(ch, start, length)
|
message.append(ch, start, length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,8 +134,7 @@ object CompilerOutputParser {
|
|||||||
|
|
||||||
if (category == OUTPUT) {
|
if (category == OUTPUT) {
|
||||||
reportToCollector(text)
|
reportToCollector(text)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
messageCollector.report(category, text, CompilerMessageLocation.create(path, line, column, null))
|
messageCollector.report(category, text, CompilerMessageLocation.create(path, line, column, null))
|
||||||
}
|
}
|
||||||
tags.pop()
|
tags.pop()
|
||||||
@@ -154,13 +149,14 @@ object CompilerOutputParser {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val CATEGORIES = mapOf(
|
private val CATEGORIES = mapOf(
|
||||||
"error" to ERROR,
|
"error" to ERROR,
|
||||||
"warning" to WARNING,
|
"warning" to WARNING,
|
||||||
"logging" to LOGGING,
|
"logging" to LOGGING,
|
||||||
"output" to OUTPUT,
|
"output" to OUTPUT,
|
||||||
"exception" to EXCEPTION,
|
"exception" to EXCEPTION,
|
||||||
"info" to INFO,
|
"info" to INFO,
|
||||||
"messages" to INFO)
|
"messages" to INFO
|
||||||
|
)
|
||||||
|
|
||||||
private fun safeParseInt(value: String?, defaultValue: Int): Int {
|
private fun safeParseInt(value: String?, defaultValue: Int): Int {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
@@ -168,8 +164,7 @@ object CompilerOutputParser {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(value.trim { it <= ' ' })
|
return Integer.parseInt(value.trim { it <= ' ' })
|
||||||
}
|
} catch (e: NumberFormatException) {
|
||||||
catch (e: NumberFormatException) {
|
|
||||||
return defaultValue
|
return defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user