Intention to simplify boolean expressions that have expressions in them that can be simplified to constants
This commit is contained in:
@@ -389,6 +389,7 @@ fun main(args: Array<String>) {
|
|||||||
model("intentions/splitIf", testMethod = "doTestSplitIf")
|
model("intentions/splitIf", testMethod = "doTestSplitIf")
|
||||||
model("intentions/replaceWithOperatorAssign", testMethod = "doTestReplaceWithOperatorAssign")
|
model("intentions/replaceWithOperatorAssign", testMethod = "doTestReplaceWithOperatorAssign")
|
||||||
model("intentions/replaceWithTraditionalAssignment", testMethod = "doTestReplaceWithTraditionalAssignment")
|
model("intentions/replaceWithTraditionalAssignment", testMethod = "doTestReplaceWithTraditionalAssignment")
|
||||||
|
model("intentions/simplifyBooleanWithConstants", testMethod = "doTestSimplifyBooleanWithConstants")
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass(javaClass<AbstractJetInspectionTest>()) {
|
testClass(javaClass<AbstractJetInspectionTest>()) {
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo() {
|
||||||
|
val x = <spot>y</spot>
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo() {
|
||||||
|
val x = <spot>3 > 2 && y && true</spot>
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
This intention simplifies a boolean expression that has parts which can be reduced to constants
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -627,6 +627,11 @@
|
|||||||
<className>org.jetbrains.jet.plugin.intentions.ConvertNegatedExpressionWithDemorgansLawIntention</className>
|
<className>org.jetbrains.jet.plugin.intentions.ConvertNegatedExpressionWithDemorgansLawIntention</className>
|
||||||
<category>Kotlin</category>
|
<category>Kotlin</category>
|
||||||
</intentionAction>
|
</intentionAction>
|
||||||
|
|
||||||
|
<intentionAction>
|
||||||
|
<className>org.jetbrains.jet.plugin.intentions.SimplifyBooleanWithConstantsIntention</className>
|
||||||
|
<category>Kotlin</category>
|
||||||
|
</intentionAction>
|
||||||
|
|
||||||
<localInspection implementationClass="org.jetbrains.jet.plugin.inspections.ExplicitGetInspection"
|
<localInspection implementationClass="org.jetbrains.jet.plugin.inspections.ExplicitGetInspection"
|
||||||
displayName="Explicit 'get'"
|
displayName="Explicit 'get'"
|
||||||
|
|||||||
@@ -291,6 +291,8 @@ replace.with.operator.assign.intention=Replace with an Operator-Assign Expressio
|
|||||||
replace.with.operator.assign.intention.family=Replace with an Operator-Assign Expression
|
replace.with.operator.assign.intention.family=Replace with an Operator-Assign Expression
|
||||||
replace.with.traditional.assignment.intention=Replace with Traditional Assignment
|
replace.with.traditional.assignment.intention=Replace with Traditional Assignment
|
||||||
replace.with.traditional.assignment.intention.family=Replace with Traditional Assignment
|
replace.with.traditional.assignment.intention.family=Replace with Traditional Assignment
|
||||||
|
simplify.boolean.with.constants=Simplify boolean expression
|
||||||
|
simplify.boolean.with.constants.family=Simplify boolean expression
|
||||||
|
|
||||||
property.is.implemented.too.many=Has implementations
|
property.is.implemented.too.many=Has implementations
|
||||||
property.is.overridden.too.many=Is overridden in subclasses
|
property.is.overridden.too.many=Is overridden in subclasses
|
||||||
|
|||||||
+137
@@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
* 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 com.intellij.openapi.editor.Editor
|
||||||
|
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||||
|
import org.jetbrains.jet.lang.psi.JetPsiUtil
|
||||||
|
import org.jetbrains.jet.lang.psi.JetExpression
|
||||||
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
|
import org.jetbrains.jet.lang.psi.JetParenthesizedExpression
|
||||||
|
import org.jetbrains.jet.lexer.JetTokens
|
||||||
|
import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils
|
||||||
|
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace
|
||||||
|
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
||||||
|
import com.intellij.psi.tree.IElementType
|
||||||
|
|
||||||
|
public class SimplifyBooleanWithConstantsIntention : JetSelfTargetingIntention<JetBinaryExpression>(
|
||||||
|
"simplify.boolean.with.constants", javaClass()) {
|
||||||
|
|
||||||
|
private var topParent : JetBinaryExpression? = null
|
||||||
|
|
||||||
|
override fun isApplicableTo(element: JetBinaryExpression): Boolean {
|
||||||
|
topParent = JetPsiUtil.getTopmostParentOfTypes(element, element.javaClass) as JetBinaryExpression? ?: element
|
||||||
|
return areThereExpressionsToBeSimplified(topParent)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun areThereExpressionsToBeSimplified(element: JetExpression?) : Boolean {
|
||||||
|
if (element == null) return false
|
||||||
|
when (element) {
|
||||||
|
is JetParenthesizedExpression -> return areThereExpressionsToBeSimplified(element.getExpression())
|
||||||
|
is JetBinaryExpression -> {
|
||||||
|
val op = element.getOperationToken()
|
||||||
|
if ((op == JetTokens.ANDAND || op == JetTokens.OROR) &&
|
||||||
|
(areThereExpressionsToBeSimplified(element.getLeft()) ||
|
||||||
|
areThereExpressionsToBeSimplified(element.getRight()))) return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return element.canBeReducedToBooleanConstant(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun applyTo(element: JetBinaryExpression, editor: Editor) {
|
||||||
|
// we know from isApplicableTo that topParent is not null
|
||||||
|
val simplified = simplifyBoolean(topParent!!)
|
||||||
|
if (simplified is JetParenthesizedExpression) {
|
||||||
|
val expr = simplified.getExpression()
|
||||||
|
if (expr != null) {
|
||||||
|
// this extra check is for the case where there are empty parentheses ()
|
||||||
|
topParent!!.replace(expr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
topParent!!.replace(simplified)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun simplifyBoolean(element: JetExpression) : JetExpression {
|
||||||
|
if (element.canBeReducedToTrue())
|
||||||
|
return JetPsiFactory.createExpression(element.getProject(), "true")
|
||||||
|
if (element.canBeReducedToFalse())
|
||||||
|
return JetPsiFactory.createExpression(element.getProject(), "false")
|
||||||
|
when (element) {
|
||||||
|
is JetParenthesizedExpression -> {
|
||||||
|
val expr = element.getExpression()
|
||||||
|
if (expr == null) return element
|
||||||
|
val simplified = simplifyBoolean(expr)
|
||||||
|
if (expr == simplified) return element
|
||||||
|
if (simplified is JetBinaryExpression) {
|
||||||
|
val simpText = simplified.getText()
|
||||||
|
if (simpText == null) return element
|
||||||
|
// wrap in new parentheses to keep the user's original format
|
||||||
|
return JetPsiFactory.createExpression(element.getProject(), "($simpText)")
|
||||||
|
}
|
||||||
|
// if we now have a simpleName, constant, or parenthesized we don't need parentheses
|
||||||
|
return simplified
|
||||||
|
}
|
||||||
|
is JetBinaryExpression -> {
|
||||||
|
val left = element.getLeft()
|
||||||
|
val right = element.getRight()
|
||||||
|
val op = element.getOperationToken()
|
||||||
|
if (left == null || right == null || op == null || (op != JetTokens.ANDAND && op != JetTokens.OROR))
|
||||||
|
return element
|
||||||
|
|
||||||
|
val simpleLeft = simplifyBoolean(left)
|
||||||
|
val simpleRight = simplifyBoolean(right)
|
||||||
|
if (simpleLeft.canBeReducedToTrue() || simpleLeft.canBeReducedToFalse())
|
||||||
|
return simplifyBooleanBinaryExpressionWithConstantOperand(simpleLeft, simpleRight, op)
|
||||||
|
if (simpleRight.canBeReducedToTrue() || simpleRight.canBeReducedToFalse())
|
||||||
|
return simplifyBooleanBinaryExpressionWithConstantOperand(simpleRight, simpleLeft, op)
|
||||||
|
|
||||||
|
val opText = element.getOperationReference().getText()
|
||||||
|
if (opText == null) return element
|
||||||
|
return JetPsiFactory.createBinaryExpression(element.getProject(), simpleLeft, opText, simpleRight)
|
||||||
|
}
|
||||||
|
else -> return element
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun simplifyBooleanBinaryExpressionWithConstantOperand(
|
||||||
|
booleanConstantOperand: JetExpression,
|
||||||
|
otherOperand: JetExpression,
|
||||||
|
operation: IElementType
|
||||||
|
): JetExpression {
|
||||||
|
assert(booleanConstantOperand.canBeReducedToBooleanConstant(null), "should only be called when we know it can be reduced")
|
||||||
|
if (booleanConstantOperand.canBeReducedToTrue() && operation == JetTokens.OROR)
|
||||||
|
return JetPsiFactory.createExpression(otherOperand.getProject(), "true")
|
||||||
|
if (booleanConstantOperand.canBeReducedToFalse() && operation == JetTokens.ANDAND)
|
||||||
|
return JetPsiFactory.createExpression(otherOperand.getProject(), "false")
|
||||||
|
return simplifyBoolean(otherOperand)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun JetExpression.canBeReducedToBooleanConstant(constant: Boolean?): Boolean {
|
||||||
|
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(this)
|
||||||
|
val trace = DelegatingBindingTrace(bindingContext, "trace for constant check")
|
||||||
|
return CompileTimeConstantUtils.canBeReducedToBooleanConstant(this, trace, constant)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun JetExpression.canBeReducedToTrue(): Boolean {
|
||||||
|
return this.canBeReducedToBooleanConstant(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun JetExpression.canBeReducedToFalse(): Boolean {
|
||||||
|
return this.canBeReducedToBooleanConstant(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo(y: Boolean) {
|
||||||
|
y && <caret>y || y
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo(y: Boolean) {
|
||||||
|
<caret>true
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo(y: Boolean) {
|
||||||
|
val x = 4
|
||||||
|
val z = 5
|
||||||
|
<caret>x < z
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo(y: Boolean) {
|
||||||
|
val x = 4
|
||||||
|
val z = 5
|
||||||
|
<caret>x == z || x != z
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun foo(y: Boolean) {
|
||||||
|
val x = true
|
||||||
|
val z = false
|
||||||
|
<caret>x && z
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
<caret>2 > 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
true
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
<caret>2 > 1 && y || y || (3 + 3 > 10)
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
y || y
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
<caret>3 != 3 && 2 > 1 || y
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
y
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
val x = 3
|
||||||
|
<caret>x != x && (2 > 1 || y)
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
val x = 3
|
||||||
|
x != x
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo() {
|
||||||
|
val x = <caret>true && false || true
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo() {
|
||||||
|
val x = true
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
(y && false) || (y && y && true && (y && true))<caret> && false && true
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
false
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
false || false || y || y ||<caret> false || y && y || y
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
y || y || y && y || y
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
y || false && true || <caret>false || false || false || y && true
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
y || y
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
false || false || y || y || <caret>false && (y && y || true)
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
y || y
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
bar() && y || <caret>(y && true && bar()) || false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(): Boolean = false
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
bar() && y || (y && bar())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(): Boolean = false
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
((y && true) || false) <caret>&& (true && (y && (y && (y ||false))))
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
y && (y && (y && y))
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
<caret>true && () && y
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
() && y
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
(false)<caret> && true
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
false
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
y || <caret>(y && true)
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(y: Boolean) {
|
||||||
|
y || y
|
||||||
|
}
|
||||||
@@ -227,6 +227,10 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
|
|||||||
doTestIntention(path, new ReplaceWithTraditionalAssignmentIntention());
|
doTestIntention(path, new ReplaceWithTraditionalAssignmentIntention());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void doTestSimplifyBooleanWithConstants(@NotNull String path) throws Exception {
|
||||||
|
doTestIntention(path, new SimplifyBooleanWithConstantsIntention());
|
||||||
|
}
|
||||||
|
|
||||||
private void doTestIntention(@NotNull String path, @NotNull IntentionAction intentionAction) throws Exception {
|
private void doTestIntention(@NotNull String path, @NotNull IntentionAction intentionAction) throws Exception {
|
||||||
configureByFile(path);
|
configureByFile(path);
|
||||||
|
|
||||||
|
|||||||
+105
-1
@@ -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 */
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@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, CodeTransformationTestGenerated.ConvertNegatedExpressionWithDemorgansLaw.class, CodeTransformationTestGenerated.SwapBinaryExpression.class, CodeTransformationTestGenerated.SplitIf.class, CodeTransformationTestGenerated.ReplaceWithOperatorAssign.class, CodeTransformationTestGenerated.ReplaceWithTraditionalAssignment.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, CodeTransformationTestGenerated.SwapBinaryExpression.class, CodeTransformationTestGenerated.SplitIf.class, CodeTransformationTestGenerated.ReplaceWithOperatorAssign.class, CodeTransformationTestGenerated.ReplaceWithTraditionalAssignment.class, CodeTransformationTestGenerated.SimplifyBooleanWithConstants.class})
|
||||||
public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest {
|
public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest {
|
||||||
@TestMetadata("idea/testData/intentions/branched/elvisToIfThen")
|
@TestMetadata("idea/testData/intentions/branched/elvisToIfThen")
|
||||||
public static class ElvisToIfThen extends AbstractCodeTransformationTest {
|
public static class ElvisToIfThen extends AbstractCodeTransformationTest {
|
||||||
@@ -3173,6 +3173,109 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/intentions/simplifyBooleanWithConstants")
|
||||||
|
public static class SimplifyBooleanWithConstants extends AbstractCodeTransformationTest {
|
||||||
|
public void testAllFilesPresentInSimplifyBooleanWithConstants() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/simplifyBooleanWithConstants"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inapplicableNoConstants.kt")
|
||||||
|
public void testInapplicableNoConstants() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/inapplicableNoConstants.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inapplicableNotBinary.kt")
|
||||||
|
public void testInapplicableNotBinary() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/inapplicableNotBinary.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inapplicableUsesVals.kt")
|
||||||
|
public void testInapplicableUsesVals() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/inapplicableUsesVals.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inapplicableUsesVals2.kt")
|
||||||
|
public void testInapplicableUsesVals2() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/inapplicableUsesVals2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inapplicableUsesVals3.kt")
|
||||||
|
public void testInapplicableUsesVals3() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/inapplicableUsesVals3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reduceableBinary.kt")
|
||||||
|
public void testReduceableBinary() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/reduceableBinary.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reduceableBinary2.kt")
|
||||||
|
public void testReduceableBinary2() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/reduceableBinary2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reduceableBinary3.kt")
|
||||||
|
public void testReduceableBinary3() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/reduceableBinary3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reduceableBinaryWithParenthese.kt")
|
||||||
|
public void testReduceableBinaryWithParenthese() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/reduceableBinaryWithParenthese.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simple.kt")
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/simple.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleWithMoreBinaries.kt")
|
||||||
|
public void testSimpleWithMoreBinaries() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/simpleWithMoreBinaries.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleWithMoreBinaries2.kt")
|
||||||
|
public void testSimpleWithMoreBinaries2() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/simpleWithMoreBinaries2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleWithMoreBinaries3.kt")
|
||||||
|
public void testSimpleWithMoreBinaries3() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/simpleWithMoreBinaries3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleWithMoreBinariesAndParentheses.kt")
|
||||||
|
public void testSimpleWithMoreBinariesAndParentheses() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/simpleWithMoreBinariesAndParentheses.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleWithMoreBinariesAndParentheses2.kt")
|
||||||
|
public void testSimpleWithMoreBinariesAndParentheses2() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/simpleWithMoreBinariesAndParentheses2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleWithMoreBinariesAndParentheses3.kt")
|
||||||
|
public void testSimpleWithMoreBinariesAndParentheses3() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/simpleWithMoreBinariesAndParentheses3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleWithNonsensical2.kt")
|
||||||
|
public void testSimpleWithNonsensical2() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/simpleWithNonsensical2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleWithParentheses.kt")
|
||||||
|
public void testSimpleWithParentheses() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/simpleWithParentheses.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleWithParentheses2.kt")
|
||||||
|
public void testSimpleWithParentheses2() throws Exception {
|
||||||
|
doTestSimplifyBooleanWithConstants("idea/testData/intentions/simplifyBooleanWithConstants/simpleWithParentheses2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite("CodeTransformationTestGenerated");
|
TestSuite suite = new TestSuite("CodeTransformationTestGenerated");
|
||||||
suite.addTestSuite(ElvisToIfThen.class);
|
suite.addTestSuite(ElvisToIfThen.class);
|
||||||
@@ -3222,6 +3325,7 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
|||||||
suite.addTestSuite(SplitIf.class);
|
suite.addTestSuite(SplitIf.class);
|
||||||
suite.addTestSuite(ReplaceWithOperatorAssign.class);
|
suite.addTestSuite(ReplaceWithOperatorAssign.class);
|
||||||
suite.addTestSuite(ReplaceWithTraditionalAssignment.class);
|
suite.addTestSuite(ReplaceWithTraditionalAssignment.class);
|
||||||
|
suite.addTestSuite(SimplifyBooleanWithConstants.class);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user