[Test] Fix diagnostics arguments rendering when quotes are present
Non-capturing `(?:)` was now needed to avoid getting an additional group that only contains the last symbol before the closing `"`. ^KT-62711 Fixed
This commit is contained in:
committed by
Space Team
parent
54de11cb58
commit
b8e2a17de1
+8
-2
@@ -16,10 +16,16 @@ object CodeMetaInfoParser {
|
||||
/*
|
||||
* ([\S&&[^,(){}]]+) -- tag, allowing all non-space characters except bracers and curly bracers
|
||||
* ([{](.*?)[}])? -- list of attributes
|
||||
* (\("(.*?)"\))? -- arguments of meta info
|
||||
* (\("((?:\\"|.)*?)"\))? -- arguments of meta info
|
||||
* (, )? -- possible separator between different infos
|
||||
*
|
||||
* Note about escaping quotes in arguments:
|
||||
* `".*?"` matches everything between `"` and the closest next `"` that follows after. `\\"`
|
||||
* enforces that escaped `"` are matched "along with" other symbols matched via `.`, so that
|
||||
* the closing quote no longer has a change to match `\\"`.
|
||||
* Note that just using `.*` would match `<!TAG("A"), RAG("B")!>` as `A"), RAG("B`.
|
||||
*/
|
||||
private val tagRegex = """([\S&&[^,(){}]]+)([{](.*?)[}])?(\("(.*?)"\))?(, )?""".toRegex()
|
||||
private val tagRegex = """([\S&&[^,(){}]]+)([{](.*?)[}])?(\("((?:\\"|.)*?)"\))?(, )?""".toRegex()
|
||||
|
||||
private class Opening(val index: Int, val tags: String, val startOffset: Int) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
||||
+3
-1
@@ -38,7 +38,9 @@ open class DiagnosticCodeMetaInfoRenderConfiguration(
|
||||
else -> DefaultErrorMessages.getRendererForDiagnostic(codeMetaInfo.diagnostic)
|
||||
}
|
||||
if (renderer is AbstractDiagnosticWithParametersRenderer) {
|
||||
renderer.renderParameters(codeMetaInfo.diagnostic).mapTo(params, Any?::toString)
|
||||
renderer.renderParameters(codeMetaInfo.diagnostic).mapTo(params) {
|
||||
it.toString().replace("\"", "\\\"")
|
||||
}
|
||||
}
|
||||
if (renderSeverity)
|
||||
params.add("severity='${codeMetaInfo.diagnostic.severity}'")
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ interface BodySpec<B, S : BodySpec<B, S>> {
|
||||
|
||||
fun test(b: BodySpec<String, *>) {
|
||||
val x = b.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>isEqualTo<!>("")
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_EXPRESSION_TYPE("[Error type: Not found recorded type for b.isEqualTo("")]")!>x<!>
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_EXPRESSION_TYPE("[Error type: Not found recorded type for b.isEqualTo(\"\")]")!>x<!>
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -16,7 +16,7 @@ expect fun onType(): @Ann2("") Any?
|
||||
// FILE: jvm.kt
|
||||
actual annotation class <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("annotation class Ann : Annotation defined in root package in file common.kt; annotation class Ann : Annotation defined in root package in file jvm.kt; Annotation `@Target(allowedTargets = {AnnotationTarget.FUNCTION, AnnotationTarget.CLASS})` is missing on actual declaration")!>Ann<!>
|
||||
|
||||
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun stringConcat(): Unit defined in root package in file common.kt; fun stringConcat(): Unit defined in root package in file jvm.kt; Annotation `@Ann2(s = "12")` is missing on actual declaration")!>stringConcat<!>() {}
|
||||
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun stringConcat(): Unit defined in root package in file common.kt; fun stringConcat(): Unit defined in root package in file jvm.kt; Annotation `@Ann2(s = \"12\")` is missing on actual declaration")!>stringConcat<!>() {}
|
||||
|
||||
// Not reported in K1, because supported starting from K2
|
||||
actual fun onType(): Any? = null
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
// !LANGUAGE: -RangeUntilOperator
|
||||
|
||||
class A {
|
||||
<!UNSUPPORTED_FEATURE("The feature "range until operator" is disabled")!>operator<!> fun rangeUntil(other: A): Iterable<A> = TODO()
|
||||
<!UNSUPPORTED_FEATURE("The feature \"range until operator\" is disabled")!>operator<!> fun rangeUntil(other: A): Iterable<A> = TODO()
|
||||
}
|
||||
|
||||
fun main(n: A, f: A) {
|
||||
for (i in f<!UNSUPPORTED_FEATURE("The feature "range until operator" is disabled")!>..<<!>n) {
|
||||
for (i in f<!UNSUPPORTED_FEATURE("The feature \"range until operator\" is disabled")!>..<<!>n) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ val x = {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
handle(<!UNSUPPORTED_FEATURE("The feature "unit conversions on arbitrary expressions" is experimental and should be enabled explicitly. You can also change the original type of this expression to (...) -> Unit")!>x<!>)
|
||||
handle(<!UNSUPPORTED_FEATURE("The feature \"unit conversions on arbitrary expressions\" is experimental and should be enabled explicitly. You can also change the original type of this expression to (...) -> Unit")!>x<!>)
|
||||
}
|
||||
|
||||
+3
-1
@@ -64,7 +64,9 @@ class FirDiagnosticCodeMetaRenderConfiguration(
|
||||
|
||||
val renderer = RootDiagnosticRendererFactory(diagnostic)
|
||||
if (renderer is AbstractKtDiagnosticWithParametersRenderer) {
|
||||
renderer.renderParameters(diagnostic).mapTo(params, Any?::toString)
|
||||
renderer.renderParameters(diagnostic).mapTo(params) {
|
||||
it.toString().replace("\"", "\\\"")
|
||||
}
|
||||
}
|
||||
|
||||
if (renderSeverity)
|
||||
|
||||
Reference in New Issue
Block a user