[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}'")
|
||||
|
||||
Reference in New Issue
Block a user