diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetArrayAccessExpression.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetArrayAccessExpression.java index 28550e9e455..78861624fbe 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetArrayAccessExpression.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetArrayAccessExpression.java @@ -51,18 +51,28 @@ public class JetArrayAccessExpression extends JetExpressionImpl implements JetRe @NotNull public JetContainerNode getIndicesNode() { - JetContainerNode indicesNode = (JetContainerNode) findChildByType(JetNodeTypes.INDICES); + JetContainerNode indicesNode = findChildByType(JetNodeTypes.INDICES); assert indicesNode != null : "Can't be null because of parser"; return indicesNode; } @NotNull public List getBracketRanges() { - PsiElement lBracket = getIndicesNode().findChildByType(JetTokens.LBRACKET); - PsiElement rBracket = getIndicesNode().findChildByType(JetTokens.RBRACKET); + PsiElement lBracket = getLeftBracket(); + PsiElement rBracket = getRightBracket(); if (lBracket == null || rBracket == null) { return Collections.emptyList(); } return Lists.newArrayList(lBracket.getTextRange(), rBracket.getTextRange()); } + + @Nullable + public PsiElement getLeftBracket() { + return getIndicesNode().findChildByType(JetTokens.LBRACKET); + } + + @Nullable + public PsiElement getRightBracket() { + return getIndicesNode().findChildByType(JetTokens.RBRACKET); + } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties index b1602555a38..b547b99140a 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties @@ -296,8 +296,6 @@ remove.unnecessary.curly.brackets.from.string.template=Remove curly braces from remove.unnecessary.curly.brackets.from.string.template.family=Remove Curly Braces From Variable insert.curly.brackets.to.string.template=Insert curly braces around variable insert.curly.brackets.to.string.template.family=Insert Curly Braces Around Variable -swap.binary.expression=Flip binary expression -swap.binary.expression.family=Flip Binary Expression add.name.to.argument.family=Add Name to Argument add.name.to.argument.single=Add name to argument\: ''{0}'' add.name.to.argument.multiple=Add name to argument... @@ -349,8 +347,6 @@ make.type.implicit.in.lambda=Make types implicit in lambda (may break code) make.type.implicit.in.lambda.family=Make Types Implicit In Lambda (May Break Code) invert.if.condition=Invert If Condition invert.if.condition.family=Invert If Condition -operator.to.function=Replace overloaded operator with function call -operator.to.function.family=Replace Overloaded Operator With Function Call convert.to.for.each.loop.intention=Replace with a for each loop convert.to.for.each.loop.intention.family=Replace with a For Each Loop convert.to.for.each.function.call.intention=Replace with a forEach function call diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/JetSelfTargetingIntention.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/JetSelfTargetingIntention.kt index 3d9e846a6c3..7976f0dbfec 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/JetSelfTargetingIntention.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/JetSelfTargetingIntention.kt @@ -16,21 +16,24 @@ package org.jetbrains.kotlin.idea.intentions +import com.intellij.codeInsight.intention.IntentionAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile -import org.jetbrains.kotlin.psi.JetElement +import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.idea.JetBundle +import org.jetbrains.kotlin.psi.JetElement import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypesAndPredicate -import com.intellij.codeInsight.intention.IntentionAction +import org.jetbrains.kotlin.psi.psiUtil.parents -public abstract class JetSelfTargetingIntention( - public val elementType: Class, +public abstract class JetSelfTargetingIntention( + public val elementType: Class, private var text: String, - private val familyName: String) + private val familyName: String = text) : IntentionAction { deprecated("Use primary constructor, no need to use i18n") - public constructor(key: String, elementType: Class) : this(elementType, JetBundle.message(key), JetBundle.message(key + ".family")) { + public constructor(key: String, elementType: Class) : this(elementType, JetBundle.message(key), JetBundle.message(key + ".family")) { } protected fun setText(text: String) { @@ -40,13 +43,28 @@ public abstract class JetSelfTargetingIntention( final override fun getText() = text final override fun getFamilyName() = familyName - public abstract fun isApplicableTo(element: T, caretOffset: Int): Boolean + public abstract fun isApplicableTo(element: TElement, caretOffset: Int): Boolean - public abstract fun applyTo(element: T, editor: Editor) + public abstract fun applyTo(element: TElement, editor: Editor) - private fun getTarget(editor: Editor, file: PsiFile): T? { + private fun getTarget(editor: Editor, file: PsiFile): TElement? { val offset = editor.getCaretModel().getOffset() - return file.findElementAt(offset)?.getParentOfTypesAndPredicate(false, elementType) { element -> isApplicableTo(element, offset) } + val leaf1 = file.findElementAt(offset) + val leaf2 = file.findElementAt(offset - 1) + val commonParent = if (leaf1 != null && leaf2 != null) PsiTreeUtil.findCommonParent(leaf1, leaf2) else null + + var elementsToCheck: Sequence = sequence { null } + if (leaf1 != null) { + elementsToCheck += leaf1.parents().takeWhile { it != commonParent } + } + if (leaf2 != null) { + elementsToCheck += leaf2.parents().takeWhile { it != commonParent } + } + if (commonParent != null) { + elementsToCheck += commonParent.parents() + } + + return elementsToCheck.filterIsInstance(elementType).firstOrNull { isApplicableTo(it, offset) } } final override fun isAvailable(project: Project, editor: Editor, file: PsiFile) @@ -62,17 +80,17 @@ public abstract class JetSelfTargetingIntention( override fun toString(): String = getText() } -public abstract class JetSelfTargetingOffsetIndependentIntention( - elementType: Class, +public abstract class JetSelfTargetingOffsetIndependentIntention( + elementType: Class, text: String, - familyName: String) -: JetSelfTargetingIntention(elementType, text, familyName) { + familyName: String = text) +: JetSelfTargetingIntention(elementType, text, familyName) { deprecated("Use primary constructor, no need to use i18n") - public constructor(key: String, elementType: Class) : this(elementType, JetBundle.message(key), JetBundle.message(key + ".family")) { + public constructor(key: String, elementType: Class) : this(elementType, JetBundle.message(key), JetBundle.message(key + ".family")) { } - public abstract fun isApplicableTo(element: T): Boolean + public abstract fun isApplicableTo(element: TElement): Boolean - override final fun isApplicableTo(element: T, caretOffset: Int): Boolean = isApplicableTo(element) + override final fun isApplicableTo(element: TElement, caretOffset: Int): Boolean = isApplicableTo(element) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt index ca60befe9c4..e9da59a840c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt @@ -16,49 +16,57 @@ package org.jetbrains.kotlin.idea.intentions -import org.jetbrains.kotlin.psi.JetExpression import com.intellij.openapi.editor.Editor -import org.jetbrains.kotlin.psi.JetPrefixExpression -import org.jetbrains.kotlin.psi.JetPostfixExpression -import org.jetbrains.kotlin.psi.JetBinaryExpression -import org.jetbrains.kotlin.psi.JetArrayAccessExpression -import org.jetbrains.kotlin.psi.JetCallExpression -import org.jetbrains.kotlin.lexer.JetTokens -import org.jetbrains.kotlin.psi.JetPsiFactory -import org.jetbrains.kotlin.psi.JetElement -import org.jetbrains.kotlin.psi.JetDotQualifiedExpression -import org.jetbrains.kotlin.resolve.BindingContext +import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.lexer.JetTokens +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall -public class OperatorToFunctionIntention : JetSelfTargetingOffsetIndependentIntention("operator.to.function", javaClass()) { +public class OperatorToFunctionIntention : JetSelfTargetingIntention(javaClass(), "Replace overloaded operator with function call") { companion object { - private fun isApplicablePrefix(element: JetPrefixExpression): Boolean { - return when (element.getOperationReference().getReferencedNameElementType()) { + private fun isApplicablePrefix(element: JetPrefixExpression, caretOffset: Int): Boolean { + val opRef = element.getOperationReference() + if (!opRef.getTextRange().containsOffset(caretOffset)) return false + return when (opRef.getReferencedNameElementType()) { JetTokens.PLUS, JetTokens.MINUS, JetTokens.PLUSPLUS, JetTokens.MINUSMINUS, JetTokens.EXCL -> true else -> false } } - private fun isApplicablePostfix(element: JetPostfixExpression): Boolean { - return when (element.getOperationReference().getReferencedNameElementType()) { + private fun isApplicablePostfix(element: JetPostfixExpression, caretOffset: Int): Boolean { + val opRef = element.getOperationReference() + if (!opRef.getTextRange().containsOffset(caretOffset)) return false + return when (opRef.getReferencedNameElementType()) { JetTokens.PLUSPLUS, JetTokens.MINUSMINUS -> true else -> false } } - private fun isApplicableBinary(element: JetBinaryExpression): Boolean { - return when (element.getOperationReference().getReferencedNameElementType()) { + private fun isApplicableBinary(element: JetBinaryExpression, caretOffset: Int): Boolean { + val opRef = element.getOperationReference() + if (!opRef.getTextRange().containsOffset(caretOffset)) return false + return when (opRef.getReferencedNameElementType()) { JetTokens.PLUS, JetTokens.MINUS, JetTokens.MUL, JetTokens.DIV, JetTokens.PERC, JetTokens.RANGE, JetTokens.IN_KEYWORD, JetTokens.NOT_IN, JetTokens.PLUSEQ, JetTokens.MINUSEQ, JetTokens.MULTEQ, JetTokens.DIVEQ, JetTokens.PERCEQ, JetTokens.EQEQ, JetTokens.EXCLEQ, JetTokens.GT, JetTokens.LT, JetTokens.GTEQ, JetTokens.LTEQ -> true JetTokens.EQ -> element.getLeft() is JetArrayAccessExpression else -> false } } - private fun isApplicableCall(element: JetCallExpression): Boolean { - val bindingContext = element.analyze() - val resolvedCall = element.getResolvedCall(bindingContext) + private fun isApplicableArrayAccess(element: JetArrayAccessExpression, caretOffset: Int): Boolean { + val lbracket = element.getLeftBracket() ?: return false + return lbracket.getTextRange().containsOffset(caretOffset) + } + + private fun isApplicableCall(element: JetCallExpression, caretOffset: Int): Boolean { + val lbrace = (element.getValueArgumentList()?.getLeftParenthesis() + ?: element.getFunctionLiteralArguments().firstOrNull()?.getFunctionLiteral()?.getLeftCurlyBrace() + ?: return false) as PsiElement + if (!lbrace.getTextRange().containsOffset(caretOffset)) return false + + val resolvedCall = element.getResolvedCall(element.analyze()) val descriptor = resolvedCall?.getResultingDescriptor() if (descriptor is FunctionDescriptor && descriptor.getName().asString() == "invoke") { val parent = element.getParent() @@ -110,7 +118,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingOffsetIndependentInte if (op == JetTokens.EQ) { if (left is JetArrayAccessExpression) { - convertArrayAccess(left as JetArrayAccessExpression) + convertArrayAccess(left) } return element } @@ -195,13 +203,13 @@ public class OperatorToFunctionIntention : JetSelfTargetingOffsetIndependentInte } } - override fun isApplicableTo(element: JetExpression): Boolean { + override fun isApplicableTo(element: JetExpression, caretOffset: Int): Boolean { return when (element) { - is JetPrefixExpression -> isApplicablePrefix(element) - is JetPostfixExpression -> isApplicablePostfix(element) - is JetBinaryExpression -> isApplicableBinary(element) - is JetArrayAccessExpression -> true - is JetCallExpression -> isApplicableCall(element) + is JetPrefixExpression -> isApplicablePrefix(element, caretOffset) + is JetPostfixExpression -> isApplicablePostfix(element, caretOffset) + is JetBinaryExpression -> isApplicableBinary(element, caretOffset) + is JetArrayAccessExpression -> isApplicableArrayAccess(element, caretOffset) + is JetCallExpression -> isApplicableCall(element, caretOffset) else -> false } } diff --git a/idea/resources/intentionDescriptions/SwapBinaryExpression/after.kt.template b/idea/resources/intentionDescriptions/SwapBinaryExpressionIntention/after.kt.template similarity index 100% rename from idea/resources/intentionDescriptions/SwapBinaryExpression/after.kt.template rename to idea/resources/intentionDescriptions/SwapBinaryExpressionIntention/after.kt.template diff --git a/idea/resources/intentionDescriptions/SwapBinaryExpression/before.kt.template b/idea/resources/intentionDescriptions/SwapBinaryExpressionIntention/before.kt.template similarity index 100% rename from idea/resources/intentionDescriptions/SwapBinaryExpression/before.kt.template rename to idea/resources/intentionDescriptions/SwapBinaryExpressionIntention/before.kt.template diff --git a/idea/resources/intentionDescriptions/SwapBinaryExpression/description.html b/idea/resources/intentionDescriptions/SwapBinaryExpressionIntention/description.html similarity index 100% rename from idea/resources/intentionDescriptions/SwapBinaryExpression/description.html rename to idea/resources/intentionDescriptions/SwapBinaryExpressionIntention/description.html diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index b5a41c2f2ae..ba491059a6e 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -745,7 +745,7 @@ - org.jetbrains.kotlin.idea.intentions.SwapBinaryExpression + org.jetbrains.kotlin.idea.intentions.SwapBinaryExpressionIntention Kotlin diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToConcatenatedStringIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToConcatenatedStringIntention.kt index f2e6433ab52..d92bb03f04c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToConcatenatedStringIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToConcatenatedStringIntention.kt @@ -16,21 +16,16 @@ package org.jetbrains.kotlin.idea.intentions -import org.jetbrains.kotlin.psi.JetStringTemplateExpression import com.intellij.openapi.editor.Editor -import org.jetbrains.kotlin.psi.JetPsiFactory -import org.jetbrains.kotlin.psi.JetStringTemplateEntry -import org.jetbrains.kotlin.psi.JetBinaryExpression -import org.jetbrains.kotlin.psi.JetStringTemplateEntryWithExpression -import org.jetbrains.kotlin.psi.JetExpression -import org.jetbrains.kotlin.resolve.BindingContextUtils import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.psi.JetIfExpression -import org.jetbrains.kotlin.psi.JetBlockExpression import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.lexer.JetTokens +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingContextUtils public class ConvertToConcatenatedStringIntention : JetSelfTargetingOffsetIndependentIntention("convert.to.concatenated.string.intention", javaClass()) { override fun isApplicableTo(element: JetStringTemplateExpression): Boolean { + if (element.getLastChild().getNode().getElementType() != JetTokens.CLOSING_QUOTE) return false // not available for unclosed literal return element.getEntries().any { it is JetStringTemplateEntryWithExpression } } @@ -39,7 +34,7 @@ public class ConvertToConcatenatedStringIntention : JetSelfTargetingOffsetIndepe val quote = if (tripleQuoted) "\"\"\"" else "\"" val entries = element.getEntries() - val result = entries.stream() + val result = entries.sequence() .mapIndexed { index, entry -> entry.toSeparateString(quote, convertExplicitly = index == 0, isFinalEntry = index == entries.size() - 1) } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SwapBinaryExpression.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SwapBinaryExpressionIntention.kt similarity index 78% rename from idea/src/org/jetbrains/kotlin/idea/intentions/SwapBinaryExpression.kt rename to idea/src/org/jetbrains/kotlin/idea/intentions/SwapBinaryExpressionIntention.kt index 8f7bf0c94e4..82f93426e42 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SwapBinaryExpression.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SwapBinaryExpressionIntention.kt @@ -24,23 +24,24 @@ import org.jetbrains.kotlin.idea.util.JetPsiPrecedences import org.jetbrains.kotlin.lexer.JetTokens.* import org.jetbrains.kotlin.types.expressions.OperatorConventions -public class SwapBinaryExpression : JetSelfTargetingOffsetIndependentIntention( - "swap.binary.expression", javaClass() -) { +public class SwapBinaryExpressionIntention : JetSelfTargetingIntention(javaClass(), "Flip binary expression") { companion object { - val SUPPORTED_OPERATIONS = setOf(PLUS, MUL, OROR, ANDAND, EQEQ, EXCLEQ, EQEQEQ, EXCLEQEQEQ, GT, LT, GTEQ, LTEQ) + private val SUPPORTED_OPERATIONS = setOf(PLUS, MUL, OROR, ANDAND, EQEQ, EXCLEQ, EQEQEQ, EXCLEQEQEQ, GT, LT, GTEQ, LTEQ) - val SUPPORTED_OPERATION_NAMES = SUPPORTED_OPERATIONS.map { OperatorConventions.BINARY_OPERATION_NAMES[it]?.asString() }.toSet().filterNotNull() + + private val SUPPORTED_OPERATION_NAMES = SUPPORTED_OPERATIONS.map { OperatorConventions.BINARY_OPERATION_NAMES[it]?.asString() }.toSet().filterNotNull() + setOf("xor", "or", "and", "equals", "identityEquals") } - override fun isApplicableTo(element: JetBinaryExpression): Boolean { + override fun isApplicableTo(element: JetBinaryExpression, caretOffset: Int): Boolean { + val opRef = element.getOperationReference() + if (!opRef.getTextRange().containsOffset(caretOffset)) return false + if (leftSubject(element) == null || rightSubject(element) == null) { return false } val operationToken = element.getOperationToken() - val operationTokenText = element.getOperationReference().getText() + val operationTokenText = opRef.getText() if (operationToken in SUPPORTED_OPERATIONS || operationToken == IDENTIFIER && operationTokenText in SUPPORTED_OPERATION_NAMES) { setText("Flip '$operationTokenText'") @@ -62,11 +63,9 @@ public class SwapBinaryExpression : JetSelfTargetingOffsetIndependentIntentioninvoke() + val f = coffee().invoke() } \ No newline at end of file diff --git a/idea/testData/intentions/operatorToFunction/notApplicableFunctionCallWithCallableReference.kt b/idea/testData/intentions/operatorToFunction/notApplicableFunctionCallWithCallableReference.kt index ee48adbfc66..d643ba97416 100644 --- a/idea/testData/intentions/operatorToFunction/notApplicableFunctionCallWithCallableReference.kt +++ b/idea/testData/intentions/operatorToFunction/notApplicableFunctionCallWithCallableReference.kt @@ -2,5 +2,5 @@ // IS_APPLICABLE: false fun foo() { val bar = { x: Int -> x + 1 } - val incremented = listOf(1, 2, 3).map(bar) + val incremented = listOf(1, 2, 3).map(bar) } \ No newline at end of file diff --git a/idea/testData/intentions/operatorToFunction/postfixMinusMinus.kt b/idea/testData/intentions/operatorToFunction/postfixMinusMinus.kt index 1e4cfb32427..9a1038986e4 100644 --- a/idea/testData/intentions/operatorToFunction/postfixMinusMinus.kt +++ b/idea/testData/intentions/operatorToFunction/postfixMinusMinus.kt @@ -1,4 +1,4 @@ fun foo() { var a = 5 - a-- + a-- } diff --git a/idea/testData/intentions/swapBinaryExpression/.intention b/idea/testData/intentions/swapBinaryExpression/.intention index 1b4eab66a90..50ea62c2292 100644 --- a/idea/testData/intentions/swapBinaryExpression/.intention +++ b/idea/testData/intentions/swapBinaryExpression/.intention @@ -1 +1 @@ -org.jetbrains.kotlin.idea.intentions.SwapBinaryExpression +org.jetbrains.kotlin.idea.intentions.SwapBinaryExpressionIntention diff --git a/idea/testData/intentions/swapBinaryExpression/greaterThan.kt b/idea/testData/intentions/swapBinaryExpression/greaterThan.kt index 1f430cc85d3..661a9a01abb 100644 --- a/idea/testData/intentions/swapBinaryExpression/greaterThan.kt +++ b/idea/testData/intentions/swapBinaryExpression/greaterThan.kt @@ -1,3 +1,3 @@ fun main() { - val ex = 4 > 5 + val ex = 4 > 5 } \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/lessThan.kt b/idea/testData/intentions/swapBinaryExpression/lessThan.kt index ee7bd214a81..aa176598dc3 100644 --- a/idea/testData/intentions/swapBinaryExpression/lessThan.kt +++ b/idea/testData/intentions/swapBinaryExpression/lessThan.kt @@ -1,3 +1,3 @@ fun main() { - val ex = 4 < 5 + val ex = 4 < 5 } \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/multipleOperands.kt b/idea/testData/intentions/swapBinaryExpression/multipleOperands.kt index dc0cbe5d7ce..3f1bdcf1211 100644 --- a/idea/testData/intentions/swapBinaryExpression/multipleOperands.kt +++ b/idea/testData/intentions/swapBinaryExpression/multipleOperands.kt @@ -1,3 +1,3 @@ fun test(a: Int, b: Int, c: Int, d: Int, e: Int): Int { - return a + b + c + d + e + return a + b + c + d + e } diff --git a/idea/testData/intentions/swapBinaryExpression/multipleOperandsWithDifferentPrecedence.kt b/idea/testData/intentions/swapBinaryExpression/multipleOperandsWithDifferentPrecedence.kt index e2ab9ea2f5f..381387c6327 100644 --- a/idea/testData/intentions/swapBinaryExpression/multipleOperandsWithDifferentPrecedence.kt +++ b/idea/testData/intentions/swapBinaryExpression/multipleOperandsWithDifferentPrecedence.kt @@ -1,3 +1,3 @@ fun main() { - val rabbit = 1 == 2 || 3 == 5 + val rabbit = 1 == 2 || 3 == 5 } \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/notEquals.kt b/idea/testData/intentions/swapBinaryExpression/notEquals.kt index 737f8705aa1..db8e78da39c 100644 --- a/idea/testData/intentions/swapBinaryExpression/notEquals.kt +++ b/idea/testData/intentions/swapBinaryExpression/notEquals.kt @@ -1,5 +1,5 @@ fun main(): Boolean { - if (5 != 20) { + if (5 != 20) { return false } return true diff --git a/idea/testData/intentions/swapBinaryExpression/notIdentityEquals.kt b/idea/testData/intentions/swapBinaryExpression/notIdentityEquals.kt index 82137198028..f1e71e322e1 100644 --- a/idea/testData/intentions/swapBinaryExpression/notIdentityEquals.kt +++ b/idea/testData/intentions/swapBinaryExpression/notIdentityEquals.kt @@ -1,3 +1,3 @@ fun neq(a: Int, b: Int) { - if (a !== b) {} + if (a !== b) {} } \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/notIdentityEquals.kt.after b/idea/testData/intentions/swapBinaryExpression/notIdentityEquals.kt.after index 9e28b22abe5..af1d64472e6 100644 --- a/idea/testData/intentions/swapBinaryExpression/notIdentityEquals.kt.after +++ b/idea/testData/intentions/swapBinaryExpression/notIdentityEquals.kt.after @@ -1,3 +1,3 @@ fun neq(a: Int, b: Int) { - if (b !== a) {} + if (b !== a) {} } \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/plus.kt b/idea/testData/intentions/swapBinaryExpression/plus.kt index d94845d2ba7..0a1c64bad36 100644 --- a/idea/testData/intentions/swapBinaryExpression/plus.kt +++ b/idea/testData/intentions/swapBinaryExpression/plus.kt @@ -1,3 +1,3 @@ fun test(a: Int, b: Int): Int { - return a + b + return a + b } diff --git a/idea/testData/intentions/swapBinaryExpression/plusInt.kt b/idea/testData/intentions/swapBinaryExpression/plusInt.kt index d94845d2ba7..0a1c64bad36 100644 --- a/idea/testData/intentions/swapBinaryExpression/plusInt.kt +++ b/idea/testData/intentions/swapBinaryExpression/plusInt.kt @@ -1,3 +1,3 @@ fun test(a: Int, b: Int): Int { - return a + b + return a + b } diff --git a/idea/testData/intentions/swapBinaryExpression/plusLiteral.kt b/idea/testData/intentions/swapBinaryExpression/plusLiteral.kt index db5bfd41ef3..db5fbae1ba3 100644 --- a/idea/testData/intentions/swapBinaryExpression/plusLiteral.kt +++ b/idea/testData/intentions/swapBinaryExpression/plusLiteral.kt @@ -1,3 +1,3 @@ fun test(a: Int, b: Int): Int { - return a plus b + return a plus b } diff --git a/idea/testData/intentions/swapBinaryExpression/timesLiteral.kt b/idea/testData/intentions/swapBinaryExpression/timesLiteral.kt index b39f3b457a5..02c2a61d053 100644 --- a/idea/testData/intentions/swapBinaryExpression/timesLiteral.kt +++ b/idea/testData/intentions/swapBinaryExpression/timesLiteral.kt @@ -1,3 +1,3 @@ fun test(a: Int, b: Int): Int { - return a times b + return a times b }