QD-7556 Fix ancestor calculation for groups

GitOrigin-RevId: c58c27f3f5e16e5aa0774b1831dc89f4f4446103
This commit is contained in:
alexey.afanasiev
2023-10-30 23:51:31 +01:00
committed by intellij-monorepo-bot
parent 3a436c20c6
commit ade3723be1

View File

@@ -16,7 +16,7 @@ class InspectionCategoryGroupProvider : InspectionGroupProvider {
override fun includesInspection(tool: InspectionToolWrapper<*, *>): Boolean {
return try {
tool.groupPath.makeCategoryId().startsWith(category)
category.isAncestor(tool.groupPath.makeCategoryId())
}
catch (e: AssertionError) {
false
@@ -26,8 +26,15 @@ class InspectionCategoryGroupProvider : InspectionGroupProvider {
}
}
private fun String.isAncestor(categoryId: String): Boolean {
if (this.isEmpty() || categoryId.isEmpty()) return false
val normalizedAncestor = this.removeSuffix("/") + "/"
val normalizedCategoryId = categoryId.removeSuffix("/") + "/"
return normalizedCategoryId.startsWith(normalizedAncestor)
}
fun Array<String>.makeCategoryId(): String {
return map { escapeToolGroupPathElement(it) }.joinToString("/")
return joinToString("/") { escapeToolGroupPathElement(it) }
}
fun escapeToolGroupPathElement(path: String): String {