From b0a333456e4b03ce6f73f09ac3a7f1d011ea7b64 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 10 Jan 2017 13:38:24 +0300 Subject: [PATCH] Platform header IDE annotation: do not report suppressed error #KT-15601 Fixed --- .../idea/highlighter/PlatformHeaderAnnotator.kt | 7 ++++++- .../platformSuppress/header/header.kt | 7 +++++++ .../platformSuppress/jvm/dummy.kt | 0 .../caches/resolve/MultiModuleHighlightingTest.kt | 12 ++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 idea/testData/multiModuleHighlighting/platformSuppress/header/header.kt create mode 100644 idea/testData/multiModuleHighlighting/platformSuppress/jvm/dummy.kt diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PlatformHeaderAnnotator.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PlatformHeaderAnnotator.kt index 8289819863e..4c29a12d9b5 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PlatformHeaderAnnotator.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PlatformHeaderAnnotator.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.highlighter import com.intellij.lang.annotation.AnnotationHolder import com.intellij.lang.annotation.Annotator import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.caches.resolve.KotlinCacheService import org.jetbrains.kotlin.descriptors.MemberDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.PlatformKind @@ -67,6 +68,10 @@ class PlatformHeaderAnnotator : Annotator { checker.checkHeaderDeclarationHasImplementation(declaration, descriptor, diagnosticSink, checkImpl = false) } - return if (diagnosticList.isNotEmpty()) SimpleDiagnostics(diagnosticList) else Diagnostics.EMPTY + val suppressionCache = KotlinCacheService.getInstance(declaration.project).getSuppressionCache() + val filteredList = diagnosticList.filter { + !suppressionCache.isSuppressed(declaration, it.factory.name, it.severity) + } + return if (filteredList.isNotEmpty()) SimpleDiagnostics(filteredList) else Diagnostics.EMPTY } } \ No newline at end of file diff --git a/idea/testData/multiModuleHighlighting/platformSuppress/header/header.kt b/idea/testData/multiModuleHighlighting/platformSuppress/header/header.kt new file mode 100644 index 00000000000..7298c666f24 --- /dev/null +++ b/idea/testData/multiModuleHighlighting/platformSuppress/header/header.kt @@ -0,0 +1,7 @@ +// See KT-15601 + +@Suppress("HEADER_WITHOUT_IMPLEMENTATION") +header interface Event + +@Suppress("SOMETHING_WRONG") +header class Wrong \ No newline at end of file diff --git a/idea/testData/multiModuleHighlighting/platformSuppress/jvm/dummy.kt b/idea/testData/multiModuleHighlighting/platformSuppress/jvm/dummy.kt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt index c74166b1d39..e14dd08dd45 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt @@ -124,4 +124,16 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() { checkHighlightingInAllFiles() } + + fun testPlatformSuppress() { + val header = module("header") + header.setPlatformKind(TargetPlatformKind.Common) + + val jvm = module("jvm") + jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6) + jvm.enableMultiPlatform() + jvm.addDependency(header) + + checkHighlightingInAllFiles() + } }