diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codeMetaInfo/CodeMetaInfoParser.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codeMetaInfo/CodeMetaInfoParser.kt index 45d44a5d788..d8e26cc5dea 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codeMetaInfo/CodeMetaInfoParser.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codeMetaInfo/CodeMetaInfoParser.kt @@ -8,11 +8,16 @@ package org.jetbrains.kotlin.codeMetaInfo import org.jetbrains.kotlin.codeMetaInfo.model.ParsedCodeMetaInfo object CodeMetaInfoParser { - private val openingRegex = "(]+?)!>)".toRegex() - private val closingRegex = "()".toRegex() + private val openingRegex = """(]+?)!>)""".toRegex() + private val closingRegex = """()""".toRegex() - private val descriptionRegex = "\\(\".*?\"\\)".toRegex() - private val platformRegex = "\\{(.+)}".toRegex() + /* + * ([\S&&[^,(){}]]+) -- tag, allowing all non-space characters except bracers and curly bracers + * ([{](.*?)[}])? -- list of platforms + * (\("(.*?)"\))? -- arguments of meta info + * (, )? -- possible separator between different infos + */ + private val tagRegex = """([\S&&[^,(){}]]+)([{](.*?)[}])?(\("(.*?)"\))?(, )?""".toRegex() fun getCodeMetaInfoFromText(renderedText: String): List { var text = renderedText @@ -48,14 +53,19 @@ object CodeMetaInfoParser { while (!openingMatchResults.isEmpty()) { val openingMatchResult = openingMatchResults.removeLast() val closingMatchResult = closingMatchResults.removeLast() - val metaInfoWithoutParams = openingMatchResult.groups[2]!!.value.replace(descriptionRegex, "") - metaInfoWithoutParams.split(",").forEach { - val tag = platformRegex.replace(it, "").trim() - val platforms = - if (platformRegex.containsMatchIn(it)) platformRegex.find(it)!!.destructured.component1().split(";") else listOf() + val allMetaInfos = openingMatchResult.groups[2]!!.value + tagRegex.findAll(allMetaInfos).map { it.groups }.forEach { + val tag = it[1]!!.value + val platforms = it[3]?.value?.split(";") ?: emptyList() + val description = it[5]?.value + result.add( ParsedCodeMetaInfo( - openingMatchResult.range.first, closingMatchResult.range.first, platforms.toMutableList(), tag, + openingMatchResult.range.first, + closingMatchResult.range.first, + platforms.toMutableList(), + tag, + description ) ) } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codeMetaInfo/model/ParsedCodeMetaInfo.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codeMetaInfo/model/ParsedCodeMetaInfo.kt index d90342af2bd..f5cc2796ff8 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codeMetaInfo/model/ParsedCodeMetaInfo.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codeMetaInfo/model/ParsedCodeMetaInfo.kt @@ -11,7 +11,8 @@ class ParsedCodeMetaInfo( override val start: Int, override val end: Int, override val platforms: MutableList, - private val tag: String + private val tag: String, + val description: String? ) : CodeMetaInfo { override val renderConfiguration = object : AbstractCodeMetaInfoRenderConfiguration(false) {}