diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt index 72617a4882e..f31158fa659 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt @@ -17,16 +17,20 @@ package org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions import com.intellij.openapi.editor.Editor +import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.idea.intentions.JetSelfTargetingOffsetIndependentIntention +import org.jetbrains.kotlin.idea.intentions.JetSelfTargetingRangeIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.convertToIfNotNullExpression import org.jetbrains.kotlin.idea.intentions.branchedTransformations.introduceValueForCondition import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isStableVariable import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsStatement -public class SafeAccessToIfThenIntention : JetSelfTargetingOffsetIndependentIntention(javaClass(), "Replace safe access expression with 'if' expression") { - override fun isApplicableTo(element: JetSafeQualifiedExpression): Boolean = element.getSelectorExpression() != null +public class SafeAccessToIfThenIntention : JetSelfTargetingRangeIntention(javaClass(), "Replace safe access expression with 'if' expression") { + override fun applicabilityRange(element: JetSafeQualifiedExpression): TextRange? { + if (element.getSelectorExpression() == null) return null + return element.getOperationTokenNode().getTextRange() + } override fun applyTo(element: JetSafeQualifiedExpression, editor: Editor) { val receiver = JetPsiUtil.safeDeparenthesize(element.getReceiverExpression())