Reduce range of IfThenTo... inspections to just 'if'

This commit is contained in:
Mikhail Glukhikh
2017-05-05 12:43:52 +03:00
parent 781a45c747
commit d9a33af61e
2 changed files with 7 additions and 2 deletions
@@ -33,7 +33,9 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
class IfThenToElvisInspection : IntentionBasedInspection<KtIfExpression>(
IfThenToElvisIntention::class,
{ it -> it.isUsedAsExpression(it.analyze(BodyResolveMode.PARTIAL)) }
)
) {
override fun inspectionTarget(element: KtIfExpression) = element.ifKeyword
}
class IfThenToElvisIntention : SelfTargetingOffsetIndependentIntention<KtIfExpression>(
KtIfExpression::class.java,
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
import org.jetbrains.kotlin.idea.intentions.SelfTargetingOffsetIndependentIntention
@@ -24,7 +25,9 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.*
import org.jetbrains.kotlin.idea.util.application.runWriteAction
import org.jetbrains.kotlin.psi.*
class IfThenToSafeAccessInspection : IntentionBasedInspection<KtIfExpression>(IfThenToSafeAccessIntention::class)
class IfThenToSafeAccessInspection : IntentionBasedInspection<KtIfExpression>(IfThenToSafeAccessIntention::class) {
override fun inspectionTarget(element: KtIfExpression) = element.ifKeyword
}
class IfThenToSafeAccessIntention : SelfTargetingOffsetIndependentIntention<KtIfExpression>(
KtIfExpression::class.java, "Replace 'if' expression with safe access expression"