Platform header IDE annotation: do not report suppressed error #KT-15601 Fixed

This commit is contained in:
Mikhail Glukhikh
2017-01-10 13:38:24 +03:00
parent 76ee6d7712
commit b0a333456e
4 changed files with 25 additions and 1 deletions
@@ -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
}
}
@@ -0,0 +1,7 @@
// See KT-15601
@Suppress("HEADER_WITHOUT_IMPLEMENTATION")
header interface Event
@Suppress("SOMETHING_WRONG")
header class <error descr="[HEADER_WITHOUT_IMPLEMENTATION] Header declaration 'Wrong' has no implementation in module for JVM">Wrong</error>
@@ -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()
}
}