Fix lines joining of TextDiagnostics on Windows
The initial assumption were that inside compiler and test framework all line breaks are normalized, because we read text files only through IDEA utils (which do normalization). The mistake was that 'StringBuilder.appendln()' appends 'System.lineSeparator()' as well, so it's not enough to only check that we don't load files from disk without normalizing whitespaces. Note that using 'it.replace(System.lineSeparator(), ...)' would be incorrect too, because actually we have strings with two kinds of line breaks here (normalized and not normalized), so we're looking for both via simple regex.
This commit is contained in:
@@ -81,7 +81,7 @@ class TextDiagnostic(
|
||||
|
||||
if (renderParameters && parameters != null) {
|
||||
result.append("(")
|
||||
result.append(StringUtil.join(parameters, { "\"${it.replace('\n', ' ')}\"" }, ", "))
|
||||
result.append(StringUtil.join(parameters, { "\"" + crossPlatformLineBreak.matcher(it).replaceAll(" ") + "\"" }, ", "))
|
||||
result.append(")")
|
||||
}
|
||||
return result.toString()
|
||||
@@ -92,6 +92,8 @@ class TextDiagnostic(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val crossPlatformLineBreak = Pattern.compile("""\r?\n""")
|
||||
|
||||
fun parseDiagnostic(text: String): TextDiagnostic {
|
||||
val matcher = CheckerTestUtil.individualDiagnosticPattern.matcher(text)
|
||||
if (!matcher.find())
|
||||
|
||||
Reference in New Issue
Block a user