J2K inspection-based processing: use more accurate isApplicable

Information level is taken into account in both base and pre-fix
isApplicable calls
This commit is contained in:
Mikhail Glukhikh
2017-12-20 16:05:42 +03:00
parent ada7287c66
commit 6b5aeaa9a6
@@ -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()
}