diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt index e794b8a8547..01d6514ba34 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/IntentionBasedInspection.kt @@ -124,15 +124,15 @@ abstract class IntentionBasedInspection( additionalFixes(targetElement)?.let { allFixes.addAll(it) } if (!allFixes.isEmpty()) { holder.registerProblem(targetElement, problemText ?: allFixes.first().name, - problemHighlightType, range, *allFixes.toTypedArray()) + problemHighlightType(targetElement), range, *allFixes.toTypedArray()) } } } } } - protected open val problemHighlightType: ProblemHighlightType - get() = ProblemHighlightType.GENERIC_ERROR_OR_WARNING + protected open fun problemHighlightType(element: TElement): ProblemHighlightType = + ProblemHighlightType.GENERIC_ERROR_OR_WARNING private fun createQuickFix( intention: SelfTargetingRangeIntention, diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/HasPlatformTypeInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/HasPlatformTypeInspection.kt index d511f3cc0dc..cdfce75b0b0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/HasPlatformTypeInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/HasPlatformTypeInspection.kt @@ -20,16 +20,12 @@ import com.intellij.codeInspection.IntentionWrapper import com.intellij.codeInspection.LocalQuickFix import com.intellij.codeInspection.ProblemHighlightType import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel -import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention import org.jetbrains.kotlin.idea.intentions.isFlexibleRecursive import org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtCallableDeclaration -import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.getNextSiblingIgnoringWhitespaceAndComments -import org.jetbrains.kotlin.psi.psiUtil.getStartOffsetIn -import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.types.TypeUtils import javax.swing.JComponent @@ -45,7 +41,7 @@ class HasPlatformTypeInspection( } ) { - override val problemHighlightType = ProblemHighlightType.WEAK_WARNING + override fun problemHighlightType(element: KtCallableDeclaration) = ProblemHighlightType.WEAK_WARNING override val problemText = "Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. " + "Specify type explicitly as nullable or non-nullable." diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyClassBodyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyClassBodyIntention.kt index ad69000d226..793699ea33a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyClassBodyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyClassBodyIntention.kt @@ -27,9 +27,10 @@ import org.jetbrains.kotlin.psi.KtSecondaryConstructor import org.jetbrains.kotlin.psi.psiUtil.getNextSiblingIgnoringWhitespaceAndComments import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -class RemoveEmptyClassBodyInspection : IntentionBasedInspection(RemoveEmptyClassBodyIntention::class), CleanupLocalInspectionTool { - override val problemHighlightType: ProblemHighlightType - get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL +class RemoveEmptyClassBodyInspection : + IntentionBasedInspection(RemoveEmptyClassBodyIntention::class), CleanupLocalInspectionTool { + override fun problemHighlightType(element: KtClassBody): ProblemHighlightType = + ProblemHighlightType.LIKE_UNUSED_SYMBOL } class RemoveEmptyClassBodyIntention : SelfTargetingOffsetIndependentIntention(KtClassBody::class.java, "Remove empty class body") { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyParenthesesFromLambdaCallIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyParenthesesFromLambdaCallIntention.kt index 40184f58ac4..327d14593f1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyParenthesesFromLambdaCallIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyParenthesesFromLambdaCallIntention.kt @@ -26,8 +26,9 @@ import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtValueArgumentList class RemoveEmptyParenthesesFromLambdaCallInspection : IntentionBasedInspection( - RemoveEmptyParenthesesFromLambdaCallIntention::class), CleanupLocalInspectionTool{ - override val problemHighlightType: ProblemHighlightType get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL + RemoveEmptyParenthesesFromLambdaCallIntention::class), CleanupLocalInspectionTool { + override fun problemHighlightType(element: KtValueArgumentList): ProblemHighlightType = + ProblemHighlightType.LIKE_UNUSED_SYMBOL } class RemoveEmptyParenthesesFromLambdaCallIntention : SelfTargetingRangeIntention( diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyPrimaryConstructorIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyPrimaryConstructorIntention.kt index d73539372ca..de4772fcf31 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyPrimaryConstructorIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyPrimaryConstructorIntention.kt @@ -23,9 +23,11 @@ import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.psi.KtPrimaryConstructor import org.jetbrains.kotlin.psi.psiUtil.containingClass -class RemoveEmptyPrimaryConstructorInspection : IntentionBasedInspection(RemoveEmptyPrimaryConstructorIntention::class), CleanupLocalInspectionTool { - override val problemHighlightType: ProblemHighlightType - get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL +class RemoveEmptyPrimaryConstructorInspection : IntentionBasedInspection( + RemoveEmptyPrimaryConstructorIntention::class +), CleanupLocalInspectionTool { + override fun problemHighlightType(element: KtPrimaryConstructor): ProblemHighlightType = + ProblemHighlightType.LIKE_UNUSED_SYMBOL } class RemoveEmptyPrimaryConstructorIntention : SelfTargetingOffsetIndependentIntention(KtPrimaryConstructor::class.java, "Remove empty primary constructor") { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptySecondaryConstructorBodyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptySecondaryConstructorBodyIntention.kt index 2146b0ef35d..f11003d2c3a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptySecondaryConstructorBodyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptySecondaryConstructorBodyIntention.kt @@ -23,9 +23,11 @@ import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.psi.KtBlockExpression import org.jetbrains.kotlin.psi.KtSecondaryConstructor -class RemoveEmptySecondaryConstructorBodyInspection : IntentionBasedInspection(RemoveEmptySecondaryConstructorBodyIntention::class), CleanupLocalInspectionTool { - override val problemHighlightType: ProblemHighlightType - get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL +class RemoveEmptySecondaryConstructorBodyInspection : IntentionBasedInspection( + RemoveEmptySecondaryConstructorBodyIntention::class +), CleanupLocalInspectionTool { + override fun problemHighlightType(element: KtBlockExpression): ProblemHighlightType = + ProblemHighlightType.LIKE_UNUSED_SYMBOL } class RemoveEmptySecondaryConstructorBodyIntention : SelfTargetingOffsetIndependentIntention(KtBlockExpression::class.java, "Remove empty constructor body") { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitSuperQualifierIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitSuperQualifierIntention.kt index d5fbe1f6d37..29462dc312d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitSuperQualifierIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitSuperQualifierIntention.kt @@ -34,9 +34,11 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.ErrorUtils -class RemoveExplicitSuperQualifierInspection : IntentionBasedInspection(RemoveExplicitSuperQualifierIntention::class), CleanupLocalInspectionTool { - override val problemHighlightType: ProblemHighlightType - get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL +class RemoveExplicitSuperQualifierInspection : IntentionBasedInspection( + RemoveExplicitSuperQualifierIntention::class +), CleanupLocalInspectionTool { + override fun problemHighlightType(element: KtSuperExpression): ProblemHighlightType = + ProblemHighlightType.LIKE_UNUSED_SYMBOL } class RemoveExplicitSuperQualifierIntention : SelfTargetingRangeIntention(KtSuperExpression::class.java, "Remove explicit supertype qualification") { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt index 73f5ff8fb78..96460e32c1a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt @@ -35,8 +35,8 @@ import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker class RemoveExplicitTypeArgumentsInspection : IntentionBasedInspection(RemoveExplicitTypeArgumentsIntention::class) { - override val problemHighlightType: ProblemHighlightType - get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL + override fun problemHighlightType(element: KtTypeArgumentList): ProblemHighlightType = + ProblemHighlightType.LIKE_UNUSED_SYMBOL } class RemoveExplicitTypeArgumentsIntention : SelfTargetingOffsetIndependentIntention(KtTypeArgumentList::class.java, "Remove explicit type arguments") { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt index 49982aa431c..3b6051dff92 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt @@ -28,7 +28,7 @@ class RemoveSetterParameterTypeInspection : IntentionBasedInspection RemoveExplicitTypeIntention.isSetterParameter(it) } ) { - override val problemHighlightType = ProblemHighlightType.LIKE_UNUSED_SYMBOL + override fun problemHighlightType(element: KtCallableDeclaration) = ProblemHighlightType.LIKE_UNUSED_SYMBOL override fun inspectionTarget(element: KtCallableDeclaration) = (element as? KtParameter)?.typeReference } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt index 7241d3fe9bb..23b4910f513 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt @@ -35,8 +35,7 @@ class RemoveForLoopIndicesInspection : IntentionBasedInspection RemoveForLoopIndicesIntention::class, "Index is not used in the loop body" ) { - override val problemHighlightType: ProblemHighlightType - get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL + override fun problemHighlightType(element: KtForExpression): ProblemHighlightType = ProblemHighlightType.LIKE_UNUSED_SYMBOL } class RemoveForLoopIndicesIntention : SelfTargetingRangeIntention(KtForExpression::class.java, "Remove indices in 'for' loop") { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveRedundantCallsOfConversionMethodsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveRedundantCallsOfConversionMethodsIntention.kt index 3b893eca7e6..6f2498e3137 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveRedundantCallsOfConversionMethodsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveRedundantCallsOfConversionMethodsIntention.kt @@ -28,8 +28,10 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.callUtil.getType import org.jetbrains.kotlin.types.isFlexible -class RemoveRedundantCallsOfConversionMethodsInspection : IntentionBasedInspection(RemoveRedundantCallsOfConversionMethodsIntention::class) { - override val problemHighlightType = ProblemHighlightType.LIKE_UNUSED_SYMBOL +class RemoveRedundantCallsOfConversionMethodsInspection : IntentionBasedInspection( + RemoveRedundantCallsOfConversionMethodsIntention::class +) { + override fun problemHighlightType(element: KtQualifiedExpression) = ProblemHighlightType.LIKE_UNUSED_SYMBOL } class RemoveRedundantCallsOfConversionMethodsIntention : SelfTargetingRangeIntention(KtQualifiedExpression::class.java, "Remove redundant calls of the conversion method") {