From bd8a4d78fa6ef22075aeb1df6c667baeb882fbf7 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 19 Jan 2018 16:10:18 +0300 Subject: [PATCH] Line Markers: Don't show test run line markers for top-level functions #KT-13509 Fixed --- .../highlighter/KotlinTestRunLineMarkerContributor.kt | 2 ++ .../topLevelFunWithKotlinTest/common/common.kt | 6 ++++++ .../topLevelFunWithKotlinTest/jvm/test.kt | 9 +++++++++ .../idea/caches/resolve/MultiModuleLineMarkerTest.kt | 4 ++++ 4 files changed, 21 insertions(+) create mode 100644 idea/testData/multiModuleLineMarker/topLevelFunWithKotlinTest/common/common.kt create mode 100644 idea/testData/multiModuleLineMarker/topLevelFunWithKotlinTest/jvm/test.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinTestRunLineMarkerContributor.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinTestRunLineMarkerContributor.kt index b5665458e5e..47a992a3c98 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinTestRunLineMarkerContributor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinTestRunLineMarkerContributor.kt @@ -142,6 +142,8 @@ class KotlinTestRunLineMarkerContributor : RunLineMarkerContributor() { if (declaration !is KtClassOrObject && declaration !is KtNamedFunction) return null + if (declaration is KtNamedFunction && declaration.containingClassOrObject == null) return null + // To prevent IDEA failing on red code val descriptor = declaration.resolveToDescriptorIfAny() ?: return null diff --git a/idea/testData/multiModuleLineMarker/topLevelFunWithKotlinTest/common/common.kt b/idea/testData/multiModuleLineMarker/topLevelFunWithKotlinTest/common/common.kt new file mode 100644 index 00000000000..3550e004b80 --- /dev/null +++ b/idea/testData/multiModuleLineMarker/topLevelFunWithKotlinTest/common/common.kt @@ -0,0 +1,6 @@ +// !CHECK_HIGHLIGHTING + +package kotlin.test + +annotation class Test +annotation class Ignore \ No newline at end of file diff --git a/idea/testData/multiModuleLineMarker/topLevelFunWithKotlinTest/jvm/test.kt b/idea/testData/multiModuleLineMarker/topLevelFunWithKotlinTest/jvm/test.kt new file mode 100644 index 00000000000..be167dc2dd9 --- /dev/null +++ b/idea/testData/multiModuleLineMarker/topLevelFunWithKotlinTest/jvm/test.kt @@ -0,0 +1,9 @@ +import kotlin.test.* + +@Test fun testFoo() { + +} + +@Ignore fun testFooWrong() { + +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt index 97a1be7b3c2..5c13a5ce462 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt @@ -110,6 +110,10 @@ class MultiModuleLineMarkerTest : AbstractMultiModuleHighlightingTest() { }) } + fun testTopLevelFunWithKotlinTest() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) + } + fun testSuspendImplInPlatformModules() { doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], TargetPlatformKind.JavaScript) }