diff --git a/plugins/kotlin/code-insight/api/src/org/jetbrains/kotlin/idea/codeinsight/api/applicable/inspections/AbstractKotlinApplicableInspectionBase.kt b/plugins/kotlin/code-insight/api/src/org/jetbrains/kotlin/idea/codeinsight/api/applicable/inspections/AbstractKotlinApplicableInspectionBase.kt index 465d32336166..e198eed92d7e 100644 --- a/plugins/kotlin/code-insight/api/src/org/jetbrains/kotlin/idea/codeinsight/api/applicable/inspections/AbstractKotlinApplicableInspectionBase.kt +++ b/plugins/kotlin/code-insight/api/src/org/jetbrains/kotlin/idea/codeinsight/api/applicable/inspections/AbstractKotlinApplicableInspectionBase.kt @@ -3,7 +3,6 @@ package org.jetbrains.kotlin.idea.codeinsight.api.applicable.inspections import com.intellij.codeInspection.* import com.intellij.codeInspection.util.InspectionMessage -import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElementVisitor import org.jetbrains.kotlin.idea.codeinsight.api.applicable.KotlinApplicableToolBase import org.jetbrains.kotlin.psi.KtElement @@ -16,12 +15,6 @@ import org.jetbrains.kotlin.psi.KtVisitor abstract class AbstractKotlinApplicableInspectionBase : LocalInspectionTool(), KotlinApplicableToolBase { - /** - * By default, a problem is registered for every [TextRange] produced by [getApplicabilityRange]. [getProblemRanges] can be overridden - * to customize this behavior, e.g. to register a problem only for the first [TextRange]. - */ - open fun getProblemRanges(ranges: List): List = ranges - internal class ProblemInfo( val description: @InspectionMessage String, val highlightType: ProblemHighlightType, @@ -43,15 +36,18 @@ abstract class AbstractKotlinApplicableInspectionBase : Loc if (!isOnTheFly && problemInfo.highlightType == ProblemHighlightType.INFORMATION) { return } - getProblemRanges(ranges).forEach { range -> - holder.registerProblem( - element, - problemInfo.description, - problemInfo.highlightType, - range, - problemInfo.quickFix, - ) - } + + ranges.asSequence() + .map { rangeInElement -> + holder.manager.createProblemDescriptor( + /* psiElement = */ element, + /* rangeInElement = */ rangeInElement, + /* descriptionTemplate = */ problemInfo.description, + /* highlightType = */ problemInfo.highlightType, + /* onTheFly = */ isOnTheFly, + /* ...fixes = */ problemInfo.quickFix, + ) + }.forEach(holder::registerProblem) } abstract override fun buildVisitor(