AbstractKotlinInspection: fix suppressor
#KT-37576 Fixed
This commit is contained in:
+4
-38
@@ -5,8 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.inspections.api
|
||||
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey
|
||||
import com.intellij.codeInspection.*
|
||||
import com.intellij.codeInspection.LocalInspectionTool
|
||||
import com.intellij.codeInspection.ProblemHighlightType
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.ide.actions.QualifiedNameProvider
|
||||
import com.intellij.lang.java.JavaLanguage
|
||||
import com.intellij.openapi.extensions.Extensions
|
||||
@@ -16,14 +17,11 @@ import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.PsiReference
|
||||
import com.intellij.util.xmlb.annotations.Attribute
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
|
||||
import org.jetbrains.kotlin.idea.KotlinJvmBundle
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.idea.highlighter.createSuppressWarningActions
|
||||
import org.jetbrains.kotlin.idea.inspections.api.IncompatibleAPIInspection.Companion.DEFAULT_REASON
|
||||
import org.jetbrains.kotlin.idea.inspections.toSeverity
|
||||
|
||||
class IncompatibleAPIInspection : LocalInspectionTool(), CustomSuppressableInspectionTool {
|
||||
class IncompatibleAPIInspection : LocalInspectionTool() {
|
||||
class Problem(
|
||||
@Attribute var reference: String? = "",
|
||||
@Attribute var reason: String? = ""
|
||||
@@ -62,38 +60,6 @@ class IncompatibleAPIInspection : LocalInspectionTool(), CustomSuppressableInspe
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSuppressActions(element: PsiElement?): Array<SuppressIntentionAction>? {
|
||||
return when {
|
||||
element == null -> emptyArray()
|
||||
|
||||
element.language == JavaLanguage.INSTANCE -> {
|
||||
val key = HighlightDisplayKey.find(shortName)
|
||||
?: throw AssertionError("HighlightDisplayKey.find($shortName) is null. Inspection: $javaClass")
|
||||
return SuppressManager.getInstance().createSuppressActions(key)
|
||||
}
|
||||
|
||||
element.language == KotlinLanguage.INSTANCE -> {
|
||||
createSuppressWarningActions(element, toSeverity(defaultLevel), suppressionKey).toTypedArray()
|
||||
}
|
||||
|
||||
else -> emptyArray()
|
||||
}
|
||||
}
|
||||
|
||||
override fun isSuppressedFor(element: PsiElement): Boolean {
|
||||
if (SuppressManager.getInstance()!!.isSuppressedFor(element, id)) {
|
||||
return true
|
||||
}
|
||||
|
||||
val project = element.project
|
||||
if (KotlinCacheService.getInstance(project).getSuppressionCache().isSuppressed(element, suppressionKey, toSeverity(defaultLevel))) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
private val suppressionKey: String get() = this.shortName
|
||||
private val problemsCache = ProblemsCache()
|
||||
|
||||
companion object {
|
||||
|
||||
Reference in New Issue
Block a user