KT-4568: Created the ConvertNegatedExpressionWithDemorgansLaw intention. Converts an expression of the form !(a &&,|| b) to its expanded equivalent under DeMorgan's law.
This commit is contained in:
committed by
Mikhael Bogdanov
parent
2147a88ed8
commit
55e888604e
@@ -380,6 +380,7 @@ fun main(args: Array<String>) {
|
||||
model("intentions/attributeCallReplacements/replaceInvokeIntention", testMethod = "doTestReplaceInvokeIntention")
|
||||
model("intentions/simplifyNegatedBinaryExpressionIntention", testMethod = "doTestSimplifyNegatedBinaryExpressionIntention")
|
||||
model("intentions/convertNegatedBooleanSequence", testMethod="doTestConvertNegatedBooleanSequence")
|
||||
model("intentions/convertNegatedExpressionWithDemorgansLaw", testMethod = "doTestConvertNegatedExpressionWithDemorgansLaw")
|
||||
}
|
||||
|
||||
testClass(javaClass<AbstractHierarchyTest>()) {
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
fun get(a: Boolean, b: Boolean): Boolean {
|
||||
return !a || !b
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
fun get(a: Boolean, b: Boolean): Boolean {
|
||||
return <spot> !(a && b)</spot>
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
This intention converts a boolean expression to an equivalent one using DeMorgan's law.
|
||||
</body>
|
||||
</html>
|
||||
@@ -619,6 +619,11 @@
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.intentions.ConvertNegatedExpressionWithDemorgansLawIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<project.converterProvider implementation="org.jetbrains.jet.plugin.converters.JetRunConfigurationSettingsFormatConverterProvider"/>
|
||||
|
||||
</extensions>
|
||||
|
||||
@@ -281,6 +281,9 @@ 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
|
||||
convert.negated.expression.with.demorgans.law=Convert negated expression to DeMorgan's equivalent
|
||||
convert.negated.expression.with.demorgans.law.family=Convert negated expression to DeMorgan's equivalent
|
||||
|
||||
|
||||
property.is.implemented.too.many=Has implementations
|
||||
property.is.overridden.too.many=Is overridden in subclasses
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.JetParenthesizedExpression
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||
import com.intellij.psi.util.PsiUtil
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import org.jetbrains.jet.lang.psi.JetPrefixExpression
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import com.intellij.psi.impl.source.tree.PsiErrorElementImpl
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
|
||||
public class ConvertNegatedExpressionWithDemorgansLawIntention : JetSelfTargetingIntention<JetPrefixExpression>(
|
||||
"convert.negated.expression.with.demorgans.law",javaClass()
|
||||
) {
|
||||
|
||||
override fun isApplicableTo(element: JetPrefixExpression): Boolean {
|
||||
val prefixOperator = element.getOperationReference().getReferencedNameElementType()
|
||||
if (prefixOperator != JetTokens.EXCL) return false
|
||||
|
||||
val parenthesizedExpression = element.getBaseExpression() as? JetParenthesizedExpression
|
||||
var binaryElement = parenthesizedExpression?.getExpression() as? JetBinaryExpression
|
||||
val operatorToken = binaryElement?.getOperationToken() ?: return false
|
||||
|
||||
if (!(operatorToken == JetTokens.ANDAND || operatorToken == JetTokens.OROR)) {
|
||||
return false
|
||||
}
|
||||
|
||||
while (binaryElement != null) { // While loop lets us handle expressions of any length
|
||||
val leftChild = binaryElement?.getLeft()
|
||||
val rightChild = binaryElement?.getRight()
|
||||
if (rightChild is PsiErrorElementImpl || operatorToken != binaryElement?.getOperationToken()) {
|
||||
return false
|
||||
}
|
||||
binaryElement = leftChild as? JetBinaryExpression
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun applyTo(element: JetPrefixExpression, editor: Editor) {
|
||||
val parenthesizedExpression = element.getBaseExpression() as JetParenthesizedExpression
|
||||
var binaryElement = parenthesizedExpression.getExpression() as? JetBinaryExpression
|
||||
val operator = binaryElement!!.getOperationToken()
|
||||
val operatorText = when(operator){
|
||||
JetTokens.ANDAND -> JetTokens.OROR.getValue()
|
||||
JetTokens.OROR -> JetTokens.ANDAND.getValue()
|
||||
else -> throw IllegalArgumentException("Invalid operator: '$operator'. Only expressions using '&&' or '||' can be converted.")
|
||||
}
|
||||
var expressionText = ""
|
||||
|
||||
while (binaryElement != null) {
|
||||
val leftChild = binaryElement?.getLeft()
|
||||
val rightChild = binaryElement?.getRight()
|
||||
|
||||
val rightChildText = rightChild!!.getText()
|
||||
expressionText = "$operatorText !$rightChildText $expressionText "
|
||||
if (leftChild !is JetBinaryExpression) {
|
||||
expressionText = "!${leftChild!!.getText()} $expressionText"
|
||||
}
|
||||
binaryElement = leftChild as? JetBinaryExpression
|
||||
}
|
||||
|
||||
val newExpression = JetPsiFactory.createExpression(element.getProject(),expressionText)
|
||||
element.replace(newExpression)
|
||||
}
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !(<caret>a && b)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !a || !b
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||
return !(a && <caret>(b && c))
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||
return !a || !(b && c)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !(<caret>a || b)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !a && !b
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||
return !(<caret>a || (b && c))
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||
return !a && !(b && c)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun String.not(): Boolean {
|
||||
return isEmpty()
|
||||
}
|
||||
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !<caret>(!"" || b)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun String.not(): Boolean {
|
||||
return isEmpty()
|
||||
}
|
||||
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !!"" && !b
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return <caret>a && b
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !<caret>(!a + b)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||
return !(<caret>a && b && c || !d)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !<caret>(a || !b || c)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !a && !!b && !c
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !<caret>(a && !b)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !a || !!b
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun Boolean.plus(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !<caret>(+a || b)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun Boolean.plus(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||
return !+a && !b
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||
return a && !(<caret>b && c)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||
return a && (!b || !c)
|
||||
}
|
||||
@@ -163,6 +163,10 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
|
||||
doTestIntention(path, new ReplaceExplicitFunctionLiteralParamWithItIntention());
|
||||
}
|
||||
|
||||
public void doTestConvertNegatedExpressionWithDemorgansLaw(@NotNull String path) throws Exception {
|
||||
doTestIntention(path, new ConvertNegatedExpressionWithDemorgansLawIntention());
|
||||
}
|
||||
|
||||
public void doTestReplaceItWithExplicitFunctionLiteralParam(@NotNull String path) throws Exception {
|
||||
doTestIntention(path, new ReplaceItWithExplicitFunctionLiteralParamIntention());
|
||||
}
|
||||
|
||||
+124
-55
@@ -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, CodeTransformationTestGenerated.ConvertNegatedBooleanSequence.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, CodeTransformationTestGenerated.ConvertNegatedExpressionWithDemorgansLaw.class})
|
||||
public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest {
|
||||
@TestMetadata("idea/testData/intentions/branched/elvisToIfThen")
|
||||
public static class ElvisToIfThen extends AbstractCodeTransformationTest {
|
||||
@@ -2602,60 +2602,7 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
||||
|
||||
}
|
||||
|
||||
@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")
|
||||
@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);
|
||||
@@ -2723,6 +2670,127 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
||||
|
||||
}
|
||||
|
||||
@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/convertNegatedExpressionWithDemorgansLaw")
|
||||
public static class ConvertNegatedExpressionWithDemorgansLaw extends AbstractCodeTransformationTest {
|
||||
public void testAllFilesPresentInConvertNegatedExpressionWithDemorgansLaw() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("conjunctionNegation1.kt")
|
||||
public void testConjunctionNegation1() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/conjunctionNegation1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conjunctionNegation2.kt")
|
||||
public void testConjunctionNegation2() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/conjunctionNegation2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("disjunctionNegation1.kt")
|
||||
public void testDisjunctionNegation1() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/disjunctionNegation1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("disjunctionNegation2.kt")
|
||||
public void testDisjunctionNegation2() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/disjunctionNegation2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doubleNegation.kt")
|
||||
public void testDoubleNegation() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inapplicableNormalExpression.kt")
|
||||
public void testInapplicableNormalExpression() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/inapplicableNormalExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inapplicableOperator.kt")
|
||||
public void testInapplicableOperator() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/inapplicableOperator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inapplicableTriple.kt")
|
||||
public void testInapplicableTriple() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/inapplicableTriple.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("longMixedExpression.kt")
|
||||
public void testLongMixedExpression() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/longMixedExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mixedExpression.kt")
|
||||
public void testMixedExpression() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/mixedExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonstandardPrefixOperator.kt")
|
||||
public void testNonstandardPrefixOperator() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/nonstandardPrefixOperator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("retainedParens.kt")
|
||||
public void testRetainedParens() throws Exception {
|
||||
doTestConvertNegatedExpressionWithDemorgansLaw("idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/retainedParens.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("CodeTransformationTestGenerated");
|
||||
suite.addTestSuite(ElvisToIfThen.class);
|
||||
@@ -2767,6 +2835,7 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
||||
suite.addTestSuite(ReplaceInvokeIntention.class);
|
||||
suite.addTestSuite(SimplifyNegatedBinaryExpressionIntention.class);
|
||||
suite.addTestSuite(ConvertNegatedBooleanSequence.class);
|
||||
suite.addTestSuite(ConvertNegatedExpressionWithDemorgansLaw.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user