KotlinSpringClassAnnotator ignores duplicate gutter handlers (IDEA-173995, KT-18298)

This commit is contained in:
Nicolay Mitropolsky
2017-06-15 14:23:00 +03:00
committed by Nikolay Krasko
parent ce77751349
commit ca19ea8205
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.idea.spring.lineMarking
import com.intellij.codeInsight.daemon.GutterIconNavigationHandler
import com.intellij.codeInsight.daemon.LineMarkerInfo
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo
import com.intellij.navigation.GotoRelatedItem
@@ -105,6 +106,7 @@ class KotlinSpringClassAnnotator : SpringClassAnnotator() {
else -> return@mapNotNullTo item
}
if (elementToAnnotate == null) return@mapNotNullTo null
if (alreadyMarked(result, elementToAnnotate, item.navigationHandler)) return@mapNotNullTo null
@Suppress("UNCHECKED_CAST")
RelatedItemLineMarkerInfo<PsiElement>(
@@ -119,4 +121,16 @@ class KotlinSpringClassAnnotator : SpringClassAnnotator() {
)
}
}
private fun alreadyMarked(result: MutableCollection<in RelatedItemLineMarkerInfo<PsiElement>>,
elementToAnnotate: PsiElement,
navigationHandler: GutterIconNavigationHandler<*>?) =
result.any {
when (it) {
is RelatedItemLineMarkerInfo<*> -> {
it.element == elementToAnnotate && it.navigationHandler == navigationHandler
}
else -> false
}
}
}