in plugin-rust-agent/src/main/kotlin/jetbrains/buildServer/rust/inspections/ClippyInspectionsParser.kt [27:55]
fun processLine(text: String): Inspection? {
return when {
text.startsWith("error: ") -> {
currentType = CLIPPY_ERROR
currentMessage = text.removePrefix("error: ")
null
}
text.startsWith("warning: ") -> {
currentType = CLIPPY_WARNING
currentMessage = text.removePrefix("warning: ")
null
}
text.matches("^\\s+--> .+".toRegex()) -> {
val position = text.replace("^\\s+--> ".toRegex(), "")
val split = position.split(":")
val filename = split.subList(0, split.size-2).joinToString(":")
val line = split[split.size-2]
Inspection(
type = currentType,
message = currentMessage,
file = filename,
line = line.toInt(),
severity = if (currentType == CLIPPY_ERROR) Inspection.Severity.ERROR else Inspection.Severity.WARNING
)
}
else -> null
}
}