From ce50a27af016f74b7f55e0c54e6fa68bf9db4b4e Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 27 Oct 2015 22:11:06 +0300 Subject: [PATCH] KT-9729 Invert If Condition intention should run Simplify Negated Expression when applicable #KT-9729 Fixed --- ...vertNegatedExpressionWithDemorgansLawIntention.kt | 4 ++++ .../idea/intentions/InvertIfConditionIntention.kt | 12 +++++++----- .../invertIfCondition/binaryExpression.kt.after | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedExpressionWithDemorgansLawIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedExpressionWithDemorgansLawIntention.kt index d177513e0b8..3f6ac25c6ab 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedExpressionWithDemorgansLawIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertNegatedExpressionWithDemorgansLawIntention.kt @@ -40,6 +40,10 @@ public class ConvertNegatedExpressionWithDemorgansLawIntention : JetSelfTargetin } override fun applyTo(element: KtPrefixExpression, editor: Editor) { + applyTo(element) + } + + fun applyTo(element: KtPrefixExpression) { val parenthesizedExpression = element.getBaseExpression() as KtParenthesizedExpression val baseExpression = parenthesizedExpression.getExpression() as KtBinaryExpression diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt index 9159ebbe61f..5ae00c09132 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt @@ -18,18 +18,14 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiDocumentManager -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiWhiteSpace -import com.intellij.psi.tree.IElementType import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.idea.quickfix.moveCaret -import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.idea.util.psi.patternMatching.matches -import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.* +import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance import org.jetbrains.kotlin.utils.addToStdlib.lastIsInstanceOrNull @@ -45,6 +41,12 @@ public class InvertIfConditionIntention : JetSelfTargetingIntention