Wrap diagnostic parameters to double quotes and split by comma instead of semicolon
This commit is contained in:
@@ -6,12 +6,9 @@
|
||||
package org.jetbrains.kotlin.checkers.diagnostics
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory1
|
||||
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil
|
||||
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil.INDIVIDUAL_PARAMETER_PATTERN
|
||||
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil.SHOULD_BE_ESCAPED
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.AbstractDiagnosticWithParametersRenderer
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticWithParameters1Renderer
|
||||
@@ -79,7 +76,7 @@ class TextDiagnostic(
|
||||
result.append(name)
|
||||
if (parameters != null) {
|
||||
result.append("(")
|
||||
result.append(StringUtil.join(parameters, { escape(it) }, "; "))
|
||||
result.append(StringUtil.join(parameters, { "\"$it\"" }, ", "))
|
||||
result.append(")")
|
||||
}
|
||||
return result.toString()
|
||||
@@ -90,13 +87,6 @@ class TextDiagnostic(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun escape(s: String): String {
|
||||
return s.replace("([$SHOULD_BE_ESCAPED])".toRegex(), "\\\\$1")
|
||||
}
|
||||
|
||||
private fun unescape(s: String): String {
|
||||
return s.replace("\\\\([$SHOULD_BE_ESCAPED])".toRegex(), "$1")
|
||||
}
|
||||
fun parseDiagnostic(text: String): TextDiagnostic {
|
||||
val matcher = CheckerTestUtil.individualDiagnosticPattern.matcher(text)
|
||||
if (!matcher.find())
|
||||
@@ -119,11 +109,12 @@ class TextDiagnostic(
|
||||
inference
|
||||
)
|
||||
|
||||
val parsedParameters = SmartList<String>()
|
||||
val parametersMatcher = INDIVIDUAL_PARAMETER_PATTERN.matcher(parameters)
|
||||
while (parametersMatcher.find())
|
||||
parsedParameters.add(unescape(parametersMatcher.group().trim({ it <= ' ' })))
|
||||
return TextDiagnostic(name, platform, parsedParameters, inference)
|
||||
return TextDiagnostic(
|
||||
name,
|
||||
platform,
|
||||
parameters.trim('"').split(Regex("""",\s*"""")),
|
||||
inference
|
||||
)
|
||||
}
|
||||
|
||||
private fun computeInferenceCompatibility(abbreviation: String?): InferenceCompatibility {
|
||||
|
||||
@@ -41,10 +41,7 @@ object CheckerTestUtil {
|
||||
const val OLD_INFERENCE_PREFIX = "OI"
|
||||
|
||||
private const val IGNORE_DIAGNOSTIC_PARAMETER = "IGNORE"
|
||||
val SHOULD_BE_ESCAPED = "\\)\\(;"
|
||||
private val DIAGNOSTIC_PARAMETER = "(?:(?:\\\\[" + SHOULD_BE_ESCAPED + "])|[^" + SHOULD_BE_ESCAPED + "])+"
|
||||
private val INDIVIDUAL_DIAGNOSTIC = "(\\w+;)?(\\w+:)?(\\w+)(\\(" + DIAGNOSTIC_PARAMETER + "(;\\s*" + DIAGNOSTIC_PARAMETER + ")*\\))?"
|
||||
val INDIVIDUAL_PARAMETER_PATTERN = Pattern.compile(DIAGNOSTIC_PARAMETER)
|
||||
private const val INDIVIDUAL_DIAGNOSTIC = """(\w+;)?(\w+:)?(\w+)(?:\(((?:".*?")(?:,\s*".*?")*)\))?"""
|
||||
|
||||
private val rangeStartOrEndPattern = Pattern.compile("(<!$INDIVIDUAL_DIAGNOSTIC(,\\s*$INDIVIDUAL_DIAGNOSTIC)*!>)|(<!>)")
|
||||
val individualDiagnosticPattern: Pattern = Pattern.compile(INDIVIDUAL_DIAGNOSTIC)
|
||||
|
||||
Reference in New Issue
Block a user