Skip to content

Commit

Permalink
kotlin-gradle-plugin: change output format
Browse files Browse the repository at this point in the history
  • Loading branch information
NataliaUkhorskaya committed Oct 7, 2014
1 parent dd0642e commit ffe8ae3
Showing 1 changed file with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,30 @@ fun getAnnotations(project: Project, logger: Logger): Collection<File> {

class GradleMessageCollector(val logger : Logger): MessageCollector {
public override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) {
val path = location.getPath()
val hasLocation = path != null && location.getLine() > 0 && location.getColumn() > 0
val text: String
if (hasLocation) {
val warningPrefix = if (severity == CompilerMessageSeverity.WARNING) "warning:" else ""
val errorMarkerLine = "${" ".repeat(location.getColumn() - 1)}^"
text = "$path:${location.getLine()}:$warningPrefix$message\n${errorMarkerLine}"
}
else {
text = "${severity.name().toLowerCase()}:$message"
val text = with(StringBuilder()) {
append(when (severity) {
in CompilerMessageSeverity.VERBOSE -> "v"
in CompilerMessageSeverity.ERRORS -> "e"
CompilerMessageSeverity.INFO -> "i"
CompilerMessageSeverity.WARNING -> "w"
else -> throw IllegalArgumentException("Unknown CompilerMessageSeverity: $severity")
})
append(": ")

val path = location.getPath()
if (path != null) {
append(path)
append(": ")
append("(")
append(location.getLine())
append(", ")
append(location.getColumn())
append("): ")
}

append(message)

toString()
}
when (severity) {
in CompilerMessageSeverity.VERBOSE -> logger.debug(text)
Expand Down

0 comments on commit ffe8ae3

Please sign in to comment.