From 51e007116fee2592c27423bdfb2ab61b9c6a5143 Mon Sep 17 00:00:00 2001 From: Nicolay Mitropolsky Date: Wed, 7 Aug 2019 14:12:49 +0300 Subject: [PATCH] KotlinLineMarkerProvider: ignore non-leaf elements when putting gutters (KT-28075, KT-30052, KT-33182) previously for instance `KtClassBody` could get here as `leaf` and `leaf.parent` will return `KtClass` for it, making gutter for `KtClass` appear twice if origingal identifier and `KtClassBody` got here in different passes (one in "inner" other in "outer") --- .../idea/highlighter/markers/KotlinLineMarkerProvider.kt | 1 + .../jvm/jvm.kt | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt index ea9ccef4e16..52a0c18a1f3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt @@ -95,6 +95,7 @@ class KotlinLineMarkerProvider : LineMarkerProviderDescriptor() { for (leaf in elements) { ProgressManager.checkCanceled() + if (leaf !is PsiIdentifier && leaf.firstChild != null) continue val element = leaf.parent as? KtNamedDeclaration ?: continue if (!declarations.add(element)) continue diff --git a/idea/testData/multiModuleLineMarker/fromActualAnnotationWithParametersInOneLine/jvm/jvm.kt b/idea/testData/multiModuleLineMarker/fromActualAnnotationWithParametersInOneLine/jvm/jvm.kt index e54dfb4587d..e44371c8b76 100644 --- a/idea/testData/multiModuleLineMarker/fromActualAnnotationWithParametersInOneLine/jvm/jvm.kt +++ b/idea/testData/multiModuleLineMarker/fromActualAnnotationWithParametersInOneLine/jvm/jvm.kt @@ -3,10 +3,6 @@ actual annotation class Ann actual val z: Double, actual val b: Boolean ) -// TODO: first marker on 'Ann' is generated twice here, see collectSlowLineMarkers main loop. -// Since it's fragile place, I don't want to fix it right now - - /* LINEMARKER: Has declaration in common module TARGETS: @@ -15,11 +11,6 @@ expect annotation class <1>Ann( *//* LINEMARKER: Has declaration in common module TARGETS: -common.kt -expect annotation class <1>Ann( -*//* -LINEMARKER: Has declaration in common module -TARGETS: common.kt val <1>x: Int, val <2>y: String, *//*