From 6b5aeaa9a6363006c141e514755f673d8ca710f2 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 20 Dec 2017 16:05:42 +0300 Subject: [PATCH] J2K inspection-based processing: use more accurate isApplicable Information level is taken into account in both base and pre-fix isApplicable calls --- .../jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt index f4dbe201f3c..c5079dc3398 100644 --- a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt +++ b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt @@ -180,14 +180,17 @@ object J2KPostProcessingRegistrar { // Inspection can either need or not need write action override val writeActionNeeded = inspection.startFixInWriteAction + private fun isApplicable(element: TElement): Boolean { + if (!inspection.isApplicable(element)) return false + return acceptInformationLevel || inspection.inspectionHighlightType(element) != ProblemHighlightType.INFORMATION + } + override fun createAction(element: KtElement, diagnostics: Diagnostics): (() -> Unit)? { if (!TElement::class.java.isInstance(element)) return null val tElement = element as TElement - if (!inspection.isApplicable(tElement)) return null - val highlightType = inspection.inspectionHighlightType(tElement) - if (!acceptInformationLevel && highlightType == ProblemHighlightType.INFORMATION) return null + if (!isApplicable(tElement)) return null return { - if (inspection.isApplicable(tElement)) { // check availability of the intention again because something could change + if (isApplicable(tElement)) { // check availability of the inspection again because something could change val apply = { inspection.applyTo(element) } apply() }