From 2147a88ed85004044fc289220750d6fcd387ab02 Mon Sep 17 00:00:00 2001 From: Ross Hanson Date: Tue, 11 Mar 2014 09:06:34 -0400 Subject: [PATCH] KT-4568: Created the ConvertNegatedBooleanSequence intention. This intention takes an expression of the form !a &&,|| !b &&,|| ... and converts it to the DeMorgan equivalent !(a &&,|| b ...). --- .../jet/generators/tests/GenerateTests.kt | 1 + .../after.kt.template | 3 + .../before.kt.template | 3 + .../description.html | 5 ++ idea/src/META-INF/plugin.xml | 6 +- .../jetbrains/jet/plugin/JetBundle.properties | 2 + .../ConvertNegatedBooleanSequenceIntention.kt | 87 +++++++++++++++++++ .../conjunctionOfThreeNegations.kt | 3 + .../conjunctionOfThreeNegations.kt.after | 3 + .../conjunctionOfTwoNegations.kt | 3 + .../conjunctionOfTwoNegations.kt.after | 3 + .../disjunctionOfTwoNegations.kt | 3 + .../disjunctionOfTwoNegations.kt.after | 3 + .../doubleParenthesizedExpression.kt | 3 + .../doubleParenthesizedExpression.kt.after | 3 + .../inapplicableMixedOperators.kt | 4 + .../inapplicableMixedSequence.kt | 4 + .../inapplicableSingleExpression.kt | 4 + .../negatedFunction.kt | 11 +++ .../negatedFunction.kt.after | 11 +++ .../parenthesizedConjunctionOfTwoNegations.kt | 3 + ...thesizedConjunctionOfTwoNegations.kt.after | 3 + .../AbstractCodeTransformationTest.java | 4 + .../CodeTransformationTestGenerated.java | 58 ++++++++++++- 24 files changed, 230 insertions(+), 3 deletions(-) create mode 100644 idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/after.kt.template create mode 100644 idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/before.kt.template create mode 100644 idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/description.html create mode 100644 idea/src/org/jetbrains/jet/plugin/intentions/ConvertNegatedBooleanSequenceIntention.kt create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfThreeNegations.kt create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfThreeNegations.kt.after create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfTwoNegations.kt create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfTwoNegations.kt.after create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/disjunctionOfTwoNegations.kt create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/disjunctionOfTwoNegations.kt.after create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/doubleParenthesizedExpression.kt create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/doubleParenthesizedExpression.kt.after create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/inapplicableMixedOperators.kt create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/inapplicableMixedSequence.kt create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/inapplicableSingleExpression.kt create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/negatedFunction.kt create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/negatedFunction.kt.after create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/parenthesizedConjunctionOfTwoNegations.kt create mode 100644 idea/testData/intentions/convertNegatedBooleanSequence/parenthesizedConjunctionOfTwoNegations.kt.after diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index e30af1d8392..58dc2655499 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -379,6 +379,7 @@ fun main(args: Array) { model("intentions/attributeCallReplacements/replaceUnaryPrefixIntention", testMethod = "doTestReplaceUnaryPrefixIntention") model("intentions/attributeCallReplacements/replaceInvokeIntention", testMethod = "doTestReplaceInvokeIntention") model("intentions/simplifyNegatedBinaryExpressionIntention", testMethod = "doTestSimplifyNegatedBinaryExpressionIntention") + model("intentions/convertNegatedBooleanSequence", testMethod="doTestConvertNegatedBooleanSequence") } testClass(javaClass()) { diff --git a/idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/after.kt.template b/idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/after.kt.template new file mode 100644 index 00000000000..22bfbbf3006 --- /dev/null +++ b/idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/after.kt.template @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean) { + return !(a || b) +} \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/before.kt.template b/idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/before.kt.template new file mode 100644 index 00000000000..25a1dd503f8 --- /dev/null +++ b/idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/before.kt.template @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean) { + return !a && !b +} \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/description.html b/idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/description.html new file mode 100644 index 00000000000..b2861311ed9 --- /dev/null +++ b/idea/resources/intentionDescriptions/ConvertNegatedBooleanSequenceIntention/description.html @@ -0,0 +1,5 @@ + + +This intention converts a sequence of negated boolean expressions with the DeMorgan equivalent. + + \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index f17b456e2a5..b72e7600921 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -611,9 +611,13 @@ org.jetbrains.jet.plugin.intentions.AddBracesIntention - Kotlin + Kotlin + + org.jetbrains.jet.plugin.intentions.ConvertNegatedBooleanSequenceIntention + Kotlin + diff --git a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties index cabd02412f0..0f5dd4eed3b 100644 --- a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties +++ b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties @@ -279,6 +279,8 @@ remove.braces=Remove braces remove.braces.family=Remove Braces add.braces=Add braces add.braces.family=Add Braces +convert.negated.boolean.sequence=Replace negated sequence with DeMorgan equivalent +convert.negated.boolean.sequence.family=Replace negated sequence with DeMorgan equivalent property.is.implemented.too.many=Has implementations property.is.overridden.too.many=Is overridden in subclasses diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/ConvertNegatedBooleanSequenceIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/ConvertNegatedBooleanSequenceIntention.kt new file mode 100644 index 00000000000..825e5033f31 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/intentions/ConvertNegatedBooleanSequenceIntention.kt @@ -0,0 +1,87 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.intentions + +import org.jetbrains.jet.lang.psi.JetBinaryExpression +import com.intellij.openapi.editor.Editor +import org.jetbrains.jet.lang.psi.JetPrefixExpression +import org.jetbrains.jet.lexer.JetTokens +import com.intellij.psi.impl.source.tree.PsiErrorElementImpl +import org.jetbrains.jet.lang.psi.JetPsiFactory +import org.jetbrains.jet.lang.psi.JetParenthesizedExpression +import org.jetbrains.jet.lang.psi.JetPsiUtil + + +public class ConvertNegatedBooleanSequenceIntention : JetSelfTargetingIntention( + "convert.negated.boolean.sequence", javaClass()) { + + override fun isApplicableTo(element: JetBinaryExpression): Boolean { + if (element.getParent() is JetBinaryExpression) return false // operate only on the longest sequence + var binaryExpression : JetBinaryExpression? = element + val originalOperator = element.getOperationToken() + + if (!(originalOperator == JetTokens.ANDAND || originalOperator == JetTokens.OROR)) { + return false + } + + do { + val leftChild = binaryExpression?.getLeft() + val rightChild = binaryExpression?.getRight() + val operator = binaryExpression?.getOperationToken() + when { + rightChild !is JetPrefixExpression, + operator != originalOperator, + !(leftChild is JetPrefixExpression || leftChild is JetBinaryExpression) -> return false + else -> binaryExpression = leftChild as? JetBinaryExpression + } + } while (binaryExpression != null) + + return true + } + + override fun applyTo(element: JetBinaryExpression, editor: Editor) { + var binaryExpression = element : JetBinaryExpression? + var expressionText = "" + val operator = binaryExpression!!.getOperationToken() + val operatorText = when(binaryExpression!!.getOperationToken()) { + JetTokens.ANDAND -> JetTokens.OROR.getValue() + JetTokens.OROR -> JetTokens.ANDAND.getValue() + else -> throw IllegalArgumentException("Invalid operator: '$operator'. Only expressions using '&&' or '||' can be converted.") + } + + while (binaryExpression != null) { + val leftChild = binaryExpression!!.getLeft() + val rightChild = binaryExpression!!.getRight() as JetPrefixExpression + expressionText = " $operatorText ${rightChild.getBaseExpression()!!.getText()}$expressionText" + if (leftChild is JetPrefixExpression) { + val leftChildText = (leftChild as JetPrefixExpression).getBaseExpression()!!.getText() + expressionText = "$leftChildText$expressionText" + } + binaryExpression = leftChild as? JetBinaryExpression + } + + val newExpression = JetPsiFactory.createExpression(element.getProject(),"!($expressionText)") + + val insertedElement = element.replace(newExpression) + val insertedElementParent = insertedElement.getParent() as? JetParenthesizedExpression ?: return + + if (JetPsiUtil.areParenthesesUseless(insertedElementParent)) { + insertedElementParent.replace(insertedElement) + } + } + +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfThreeNegations.kt b/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfThreeNegations.kt new file mode 100644 index 00000000000..49840996d70 --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfThreeNegations.kt @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean) { + return !a && !b && !c +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfThreeNegations.kt.after b/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfThreeNegations.kt.after new file mode 100644 index 00000000000..b83285c0ace --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfThreeNegations.kt.after @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean) { + return !(a || b || c) +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfTwoNegations.kt b/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfTwoNegations.kt new file mode 100644 index 00000000000..4678b24a3eb --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfTwoNegations.kt @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean) { + return !a && !b +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfTwoNegations.kt.after b/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfTwoNegations.kt.after new file mode 100644 index 00000000000..e73961dec90 --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfTwoNegations.kt.after @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean) { + return !(a || b) +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/disjunctionOfTwoNegations.kt b/idea/testData/intentions/convertNegatedBooleanSequence/disjunctionOfTwoNegations.kt new file mode 100644 index 00000000000..c3c9377836b --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/disjunctionOfTwoNegations.kt @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean) { + return !a || !b +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/disjunctionOfTwoNegations.kt.after b/idea/testData/intentions/convertNegatedBooleanSequence/disjunctionOfTwoNegations.kt.after new file mode 100644 index 00000000000..c7b27760bc3 --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/disjunctionOfTwoNegations.kt.after @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean) { + return !(a && b) +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/doubleParenthesizedExpression.kt b/idea/testData/intentions/convertNegatedBooleanSequence/doubleParenthesizedExpression.kt new file mode 100644 index 00000000000..f6e5801bc00 --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/doubleParenthesizedExpression.kt @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean, c: Boolean) { + return !(a && b) || !(a || c) +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/doubleParenthesizedExpression.kt.after b/idea/testData/intentions/convertNegatedBooleanSequence/doubleParenthesizedExpression.kt.after new file mode 100644 index 00000000000..7e0380a1434 --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/doubleParenthesizedExpression.kt.after @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean, c: Boolean) { + return !((a && b) && (a || c)) +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/inapplicableMixedOperators.kt b/idea/testData/intentions/convertNegatedBooleanSequence/inapplicableMixedOperators.kt new file mode 100644 index 00000000000..f0f2ab1fdd1 --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/inapplicableMixedOperators.kt @@ -0,0 +1,4 @@ +// IS_APPLICABLE: false +fun foo(a: Boolean, b: Boolean, c: Boolean) { + return !a && !b || !c +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/inapplicableMixedSequence.kt b/idea/testData/intentions/convertNegatedBooleanSequence/inapplicableMixedSequence.kt new file mode 100644 index 00000000000..9a00ea9e04b --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/inapplicableMixedSequence.kt @@ -0,0 +1,4 @@ +// IS_APPLICABLE: false +fun foo(a: Boolean, b: boolean) { + return !a && b +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/inapplicableSingleExpression.kt b/idea/testData/intentions/convertNegatedBooleanSequence/inapplicableSingleExpression.kt new file mode 100644 index 00000000000..67006f8d882 --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/inapplicableSingleExpression.kt @@ -0,0 +1,4 @@ +// IS_APPLICABLE: false +fun foo(a: Boolean) { + return !a +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/negatedFunction.kt b/idea/testData/intentions/convertNegatedBooleanSequence/negatedFunction.kt new file mode 100644 index 00000000000..ec0f7b9e15f --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/negatedFunction.kt @@ -0,0 +1,11 @@ +fun bar1() { + return true +} + +fun bar2() { + return false +} + +fun foo() { + return !bar1() && !bar2() +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/negatedFunction.kt.after b/idea/testData/intentions/convertNegatedBooleanSequence/negatedFunction.kt.after new file mode 100644 index 00000000000..d4ff0111043 --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/negatedFunction.kt.after @@ -0,0 +1,11 @@ +fun bar1() { + return true +} + +fun bar2() { + return false +} + +fun foo() { + return !(bar1() || bar2()) +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/parenthesizedConjunctionOfTwoNegations.kt b/idea/testData/intentions/convertNegatedBooleanSequence/parenthesizedConjunctionOfTwoNegations.kt new file mode 100644 index 00000000000..087a3aa1d27 --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/parenthesizedConjunctionOfTwoNegations.kt @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean) { + return (!a && !b) +} \ No newline at end of file diff --git a/idea/testData/intentions/convertNegatedBooleanSequence/parenthesizedConjunctionOfTwoNegations.kt.after b/idea/testData/intentions/convertNegatedBooleanSequence/parenthesizedConjunctionOfTwoNegations.kt.after new file mode 100644 index 00000000000..e73961dec90 --- /dev/null +++ b/idea/testData/intentions/convertNegatedBooleanSequence/parenthesizedConjunctionOfTwoNegations.kt.after @@ -0,0 +1,3 @@ +fun foo(a: Boolean, b: Boolean) { + return !(a || b) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java b/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java index 4d452ad72f8..11477121ba2 100644 --- a/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java @@ -175,6 +175,10 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes doTestIntention(path, new AddBracesIntention()); } + public void doTestConvertNegatedBooleanSequence(@NotNull String path) throws Exception { + doTestIntention(path, new ConvertNegatedBooleanSequenceIntention()); + } + public void doTestReplaceGetIntention(@NotNull String path) throws Exception { doTestIntention(path, new TestableReplaceGetIntention()); } diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java index eedd02d0748..8c61e3d7bd1 100644 --- a/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java @@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.intentions.AbstractCodeTransformationTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") -@InnerTestClasses({CodeTransformationTestGenerated.ElvisToIfThen.class, CodeTransformationTestGenerated.IfThenToElvis.class, CodeTransformationTestGenerated.SafeAccessToIfThen.class, CodeTransformationTestGenerated.IfThenToSafeAccess.class, CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class, CodeTransformationTestGenerated.ReplaceExplicitFunctionLiteralParamWithIt.class, CodeTransformationTestGenerated.ReplaceItWithExplicitFunctionLiteralParam.class, CodeTransformationTestGenerated.RemoveBraces.class, CodeTransformationTestGenerated.AddBraces.class, CodeTransformationTestGenerated.ReplaceGetIntention.class, CodeTransformationTestGenerated.ReplaceContainsIntention.class, CodeTransformationTestGenerated.ReplaceBinaryInfixIntention.class, CodeTransformationTestGenerated.ReplaceUnaryPrefixIntention.class, CodeTransformationTestGenerated.ReplaceInvokeIntention.class, CodeTransformationTestGenerated.SimplifyNegatedBinaryExpressionIntention.class}) +@InnerTestClasses({CodeTransformationTestGenerated.ElvisToIfThen.class, CodeTransformationTestGenerated.IfThenToElvis.class, CodeTransformationTestGenerated.SafeAccessToIfThen.class, CodeTransformationTestGenerated.IfThenToSafeAccess.class, CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class, CodeTransformationTestGenerated.ReplaceExplicitFunctionLiteralParamWithIt.class, CodeTransformationTestGenerated.ReplaceItWithExplicitFunctionLiteralParam.class, CodeTransformationTestGenerated.RemoveBraces.class, CodeTransformationTestGenerated.AddBraces.class, CodeTransformationTestGenerated.ReplaceGetIntention.class, CodeTransformationTestGenerated.ReplaceContainsIntention.class, CodeTransformationTestGenerated.ReplaceBinaryInfixIntention.class, CodeTransformationTestGenerated.ReplaceUnaryPrefixIntention.class, CodeTransformationTestGenerated.ReplaceInvokeIntention.class, CodeTransformationTestGenerated.SimplifyNegatedBinaryExpressionIntention.class, CodeTransformationTestGenerated.ConvertNegatedBooleanSequence.class}) public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest { @TestMetadata("idea/testData/intentions/branched/elvisToIfThen") public static class ElvisToIfThen extends AbstractCodeTransformationTest { @@ -2602,7 +2602,60 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT } - @TestMetadata("idea/testData/intentions/simplifyNegatedBinaryExpressionIntention") + @TestMetadata("idea/testData/intentions/convertNegatedBooleanSequence") + public static class ConvertNegatedBooleanSequence extends AbstractCodeTransformationTest { + public void testAllFilesPresentInConvertNegatedBooleanSequence() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/convertNegatedBooleanSequence"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("conjunctionOfThreeNegations.kt") + public void testConjunctionOfThreeNegations() throws Exception { + doTestConvertNegatedBooleanSequence("idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfThreeNegations.kt"); + } + + @TestMetadata("conjunctionOfTwoNegations.kt") + public void testConjunctionOfTwoNegations() throws Exception { + doTestConvertNegatedBooleanSequence("idea/testData/intentions/convertNegatedBooleanSequence/conjunctionOfTwoNegations.kt"); + } + + @TestMetadata("disjunctionOfTwoNegations.kt") + public void testDisjunctionOfTwoNegations() throws Exception { + doTestConvertNegatedBooleanSequence("idea/testData/intentions/convertNegatedBooleanSequence/disjunctionOfTwoNegations.kt"); + } + + @TestMetadata("doubleParenthesizedExpression.kt") + public void testDoubleParenthesizedExpression() throws Exception { + doTestConvertNegatedBooleanSequence("idea/testData/intentions/convertNegatedBooleanSequence/doubleParenthesizedExpression.kt"); + } + + @TestMetadata("inapplicableMixedOperators.kt") + public void testInapplicableMixedOperators() throws Exception { + doTestConvertNegatedBooleanSequence("idea/testData/intentions/convertNegatedBooleanSequence/inapplicableMixedOperators.kt"); + } + + @TestMetadata("inapplicableMixedSequence.kt") + public void testInapplicableMixedSequence() throws Exception { + doTestConvertNegatedBooleanSequence("idea/testData/intentions/convertNegatedBooleanSequence/inapplicableMixedSequence.kt"); + } + + @TestMetadata("inapplicableSingleExpression.kt") + public void testInapplicableSingleExpression() throws Exception { + doTestConvertNegatedBooleanSequence("idea/testData/intentions/convertNegatedBooleanSequence/inapplicableSingleExpression.kt"); + } + + @TestMetadata("negatedFunction.kt") + public void testNegatedFunction() throws Exception { + doTestConvertNegatedBooleanSequence("idea/testData/intentions/convertNegatedBooleanSequence/negatedFunction.kt"); + } + + @TestMetadata("parenthesizedConjunctionOfTwoNegations.kt") + public void testParenthesizedConjunctionOfTwoNegations() throws Exception { + doTestConvertNegatedBooleanSequence("idea/testData/intentions/convertNegatedBooleanSequence/parenthesizedConjunctionOfTwoNegations.kt"); + } + + } + + @TestMetadata("idea/testData/intentions/simplifyNegatedBinaryExpressionIntention") public static class SimplifyNegatedBinaryExpressionIntention extends AbstractCodeTransformationTest { public void testAllFilesPresentInSimplifyNegatedBinaryExpressionIntention() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/simplifyNegatedBinaryExpressionIntention"), Pattern.compile("^(.+)\\.kt$"), true); @@ -2713,6 +2766,7 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT suite.addTestSuite(ReplaceUnaryPrefixIntention.class); suite.addTestSuite(ReplaceInvokeIntention.class); suite.addTestSuite(SimplifyNegatedBinaryExpressionIntention.class); + suite.addTestSuite(ConvertNegatedBooleanSequence.class); return suite; } }