From bc361363d5c44941be216653d3b74cca35c47d64 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 20 Dec 2017 20:41:50 +0300 Subject: [PATCH] Refactoring: "simplify negated binary expression" is now an inspection --- .../after.kt.template | 3 - .../before.kt.template | 3 - .../description.html | 7 -- idea/src/META-INF/plugin.xml | 7 +- .../NullableBooleanElvisInspection.kt | 7 +- ...mplifyNegatedBinaryExpressionInspection.kt | 100 ++++++++++++++++++ .../ConvertAssertToIfWithThrowIntention.kt | 7 +- .../ConvertIfWithThrowToAssertIntention.kt | 7 +- ...implifyNegatedBinaryExpressionIntention.kt | 83 --------------- .../kotlin/idea/j2k/J2kPostProcessings.kt | 2 +- .../.inspection | 1 + .../simplifyNegatedBinaryExpression/equals.kt | 4 + .../equals.kt.after | 4 + .../greaterThan.kt | 4 + .../greaterThan.kt.after | 4 + .../greaterThanOrEquals.kt | 4 + .../greaterThanOrEquals.kt.after | 4 + .../simplifyNegatedBinaryExpression/in.kt | 2 +- .../in.kt.after | 2 +- .../inapplicableBinaryOperation.kt | 2 +- .../inspectionData/expected.xml | 40 +++---- .../inspectionData/inspections.test | 1 + .../simplifyNegatedBinaryExpression/is.kt | 4 + .../is.kt.after | 4 + .../lessThan.kt | 4 + .../lessThan.kt.after | 4 + .../lessThanOrEquals.kt | 4 + .../lessThanOrEquals.kt.after | 4 + .../notEquals.kt | 4 + .../notEquals.kt.after | 4 + .../simplifyNegatedBinaryExpression/notIn.kt | 2 +- .../notIn.kt.after | 2 +- .../simplifyNegatedBinaryExpression/notIs.kt | 4 + .../notIs.kt.after | 4 + .../simpleInvert.kt | 2 +- .../.intention | 1 - .../simplifyNegatedBinaryExpression/equals.kt | 4 - .../equals.kt.after | 4 - .../greaterThan.kt | 4 - .../greaterThan.kt.after | 4 - .../greaterThanOrEquals.kt | 4 - .../greaterThanOrEquals.kt.after | 4 - .../inspectionData/inspections.test | 1 - .../simplifyNegatedBinaryExpression/is.kt | 4 - .../is.kt.after | 4 - .../lessThan.kt | 4 - .../lessThan.kt.after | 4 - .../lessThanOrEquals.kt | 4 - .../lessThanOrEquals.kt.after | 4 - .../notEquals.kt | 4 - .../notEquals.kt.after | 4 - .../simplifyNegatedBinaryExpression/notIs.kt | 4 - .../notIs.kt.after | 4 - .../codeInsight/InspectionTestGenerated.java | 12 +-- .../LocalInspectionTestGenerated.java | 81 ++++++++++++++ .../intentions/IntentionTestGenerated.java | 81 -------------- 56 files changed, 292 insertions(+), 292 deletions(-) delete mode 100644 idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/after.kt.template delete mode 100644 idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/before.kt.template delete mode 100644 idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/description.html create mode 100644 idea/src/org/jetbrains/kotlin/idea/inspections/SimplifyNegatedBinaryExpressionInspection.kt delete mode 100644 idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyNegatedBinaryExpressionIntention.kt create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/.inspection create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/equals.kt create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/equals.kt.after create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThan.kt create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThan.kt.after create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt.after rename idea/testData/{intentions => inspectionsLocal}/simplifyNegatedBinaryExpression/in.kt (69%) rename idea/testData/{intentions => inspectionsLocal}/simplifyNegatedBinaryExpression/in.kt.after (67%) rename idea/testData/{intentions => inspectionsLocal}/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt (78%) rename idea/testData/{intentions => inspectionsLocal}/simplifyNegatedBinaryExpression/inspectionData/expected.xml (62%) create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/inspections.test create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/is.kt create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/is.kt.after create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThan.kt create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThan.kt.after create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThanOrEquals.kt create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThanOrEquals.kt.after create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notEquals.kt create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notEquals.kt.after rename idea/testData/{intentions => inspectionsLocal}/simplifyNegatedBinaryExpression/notIn.kt (69%) rename idea/testData/{intentions => inspectionsLocal}/simplifyNegatedBinaryExpression/notIn.kt.after (67%) create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIs.kt create mode 100644 idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIs.kt.after rename idea/testData/{intentions => inspectionsLocal}/simplifyNegatedBinaryExpression/simpleInvert.kt (60%) delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/.intention delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/equals.kt delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/equals.kt.after delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThan.kt delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThan.kt.after delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt.after delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/inspections.test delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/is.kt delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/is.kt.after delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/lessThan.kt delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/lessThan.kt.after delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/lessThanOrEquals.kt delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/lessThanOrEquals.kt.after delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/notEquals.kt delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/notEquals.kt.after delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/notIs.kt delete mode 100644 idea/testData/intentions/simplifyNegatedBinaryExpression/notIs.kt.after diff --git a/idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/after.kt.template b/idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/after.kt.template deleted file mode 100644 index 771d5f518f9..00000000000 --- a/idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/after.kt.template +++ /dev/null @@ -1,3 +0,0 @@ -if (a != b) { - println("Not Equal") -} diff --git a/idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/before.kt.template b/idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/before.kt.template deleted file mode 100644 index b55588746f2..00000000000 --- a/idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/before.kt.template +++ /dev/null @@ -1,3 +0,0 @@ -if (!(a == b)) { - println("Not Equal") -} diff --git a/idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/description.html b/idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/description.html deleted file mode 100644 index db74677e7ff..00000000000 --- a/idea/resources/intentionDescriptions/SimplifyNegatedBinaryExpressionIntention/description.html +++ /dev/null @@ -1,7 +0,0 @@ - - -This intention simplifies negated binary expressions by replacing expressions such as -!(a op b) with a negop b -(where op and negop are inverse comparison operators like == and != or in and !in). - - \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index e255d6a107a..8c2745e6207 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -907,11 +907,6 @@ Kotlin - - org.jetbrains.kotlin.idea.intentions.SimplifyNegatedBinaryExpressionIntention - Kotlin - - org.jetbrains.kotlin.idea.intentions.RemoveUnnecessaryParenthesesIntention Kotlin @@ -1642,7 +1637,7 @@ language="kotlin" /> - (strict = true) ?: return - val simplifier = SimplifyNegatedBinaryExpressionIntention() - if (simplifier.isApplicableTo(prefixExpression)) { - simplifier.applyTo(prefixExpression, null) + val simplifier = SimplifyNegatedBinaryExpressionInspection() + if (simplifier.isApplicable(prefixExpression)) { + simplifier.applyTo(prefixExpression.operationReference) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/SimplifyNegatedBinaryExpressionInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/SimplifyNegatedBinaryExpressionInspection.kt new file mode 100644 index 00000000000..542c8a7e75f --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/SimplifyNegatedBinaryExpressionInspection.kt @@ -0,0 +1,100 @@ +/* + * Copyright 2010-2017 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.kotlin.idea.inspections + +import com.intellij.codeInspection.LocalInspectionToolSession +import com.intellij.codeInspection.ProblemsHolder +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElement +import com.intellij.psi.tree.IElementType +import org.jetbrains.kotlin.idea.inspections.AbstractApplicabilityBasedInspection +import org.jetbrains.kotlin.lexer.KtSingleValueToken +import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.psi.* + +class SimplifyNegatedBinaryExpressionInspection : AbstractApplicabilityBasedInspection() { + override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): KtVisitorVoid = + object : KtVisitorVoid() { + override fun visitPrefixExpression(expression: KtPrefixExpression) { + super.visitPrefixExpression(expression) + visitTargetElement(expression, holder, isOnTheFly) + } + } + + private fun IElementType.negate(): KtSingleValueToken? = when (this) { + KtTokens.IN_KEYWORD -> KtTokens.NOT_IN + KtTokens.NOT_IN -> KtTokens.IN_KEYWORD + + KtTokens.IS_KEYWORD -> KtTokens.NOT_IS + KtTokens.NOT_IS -> KtTokens.IS_KEYWORD + + KtTokens.EQEQ -> KtTokens.EXCLEQ + KtTokens.EXCLEQ -> KtTokens.EQEQ + + KtTokens.LT -> KtTokens.GTEQ + KtTokens.GTEQ -> KtTokens.LT + + KtTokens.GT -> KtTokens.LTEQ + KtTokens.LTEQ -> KtTokens.GT + + else -> null + } + + override fun inspectionTarget(element: KtPrefixExpression) = element.operationReference + + override fun inspectionText(element: KtPrefixExpression) = "Negated expression can be simplified" + + override val defaultFixText = "Simplify negated expression" + + override fun fixText(element: KtPrefixExpression): String { + val expression = KtPsiUtil.deparenthesize(element.baseExpression) as? KtOperationExpression ?: return defaultFixText + val operation = expression.operationReference.getReferencedNameElementType() as? KtSingleValueToken ?: return defaultFixText + val negatedOperation = operation.negate() ?: return defaultFixText + return "Simplify negated '${operation.value}' expression to '${negatedOperation.value}'" + } + + override fun isApplicable(element: KtPrefixExpression): Boolean { + if (element.operationToken != KtTokens.EXCL) return false + + val expression = KtPsiUtil.deparenthesize(element.baseExpression) as? KtOperationExpression ?: return false + when (expression) { + is KtIsExpression -> if (expression.typeReference == null) return false + is KtBinaryExpression -> if (expression.left == null || expression.right == null) return false + else -> return false + } + + return (expression.operationReference.getReferencedNameElementType() as? KtSingleValueToken)?.negate() != null + } + + override fun applyTo(element: PsiElement, project: Project, editor: Editor?) { + val prefixExpression = element.parent as? KtPrefixExpression ?: return + val expression = KtPsiUtil.deparenthesize(prefixExpression.baseExpression) ?: return + val operation = (expression as KtOperationExpression).operationReference.getReferencedNameElementType().negate()?.value ?: return + + val psiFactory = KtPsiFactory(expression) + val newExpression = when (expression) { + is KtIsExpression -> + psiFactory.createExpressionByPattern("$0 $1 $2", expression.leftHandSide, operation, expression.typeReference!!) + is KtBinaryExpression -> + psiFactory.createExpressionByPattern("$0 $1 $2", expression.left!!, operation, expression.right!!) + else -> + throw IllegalArgumentException() + } + prefixExpression.replace(newExpression) + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt index 73863dc9cb3..c8c2b8d25f4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.idea.core.ShortenReferences +import org.jetbrains.kotlin.idea.inspections.SimplifyNegatedBinaryExpressionInspection import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils @@ -104,9 +105,9 @@ class ConvertAssertToIfWithThrowIntention : SelfTargetingIntention(SimplifyNegatedBinaryExpressionIntention::class) - -class SimplifyNegatedBinaryExpressionIntention : SelfTargetingRangeIntention(KtPrefixExpression::class.java, "Simplify negated binary expression") { - - private fun IElementType.negate(): KtSingleValueToken? = when (this) { - KtTokens.IN_KEYWORD -> KtTokens.NOT_IN - KtTokens.NOT_IN -> KtTokens.IN_KEYWORD - - KtTokens.IS_KEYWORD -> KtTokens.NOT_IS - KtTokens.NOT_IS -> KtTokens.IS_KEYWORD - - KtTokens.EQEQ -> KtTokens.EXCLEQ - KtTokens.EXCLEQ -> KtTokens.EQEQ - - KtTokens.LT -> KtTokens.GTEQ - KtTokens.GTEQ -> KtTokens.LT - - KtTokens.GT -> KtTokens.LTEQ - KtTokens.LTEQ -> KtTokens.GT - - else -> null - } - - override fun applicabilityRange(element: KtPrefixExpression): TextRange? { - return if (isApplicableTo(element)) element.operationReference.textRange else null - } - - fun isApplicableTo(element: KtPrefixExpression): Boolean { - if (element.operationToken != KtTokens.EXCL) return false - - val expression = KtPsiUtil.deparenthesize(element.baseExpression) as? KtOperationExpression ?: return false - when (expression) { - is KtIsExpression -> { if (expression.typeReference == null) return false } - is KtBinaryExpression -> { if (expression.left == null || expression.right == null) return false } - else -> return false - } - - val operation = expression.operationReference.getReferencedNameElementType() as? KtSingleValueToken ?: return false - val negatedOperation = operation.negate() ?: return false - - text = "Simplify negated '${operation.value}' expression to '${negatedOperation.value}'" - return true - } - - override fun applyTo(element: KtPrefixExpression, editor: Editor?) { - val expression = KtPsiUtil.deparenthesize(element.baseExpression)!! - val operation = (expression as KtOperationExpression).operationReference.getReferencedNameElementType().negate()!!.value - - val psiFactory = KtPsiFactory(expression) - val newExpression = when (expression) { - is KtIsExpression -> psiFactory.createExpressionByPattern("$0 $1 $2", expression.leftHandSide, operation, expression.typeReference!!) - is KtBinaryExpression -> psiFactory.createExpressionByPattern("$0 $1 $2", expression.left!!, operation, expression.right!!) - else -> throw IllegalArgumentException() - } - element.replace(newExpression) - } -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt index 786ca52433f..49d5a19023d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt +++ b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt @@ -89,7 +89,7 @@ object J2KPostProcessingRegistrar { registerInspectionBasedProcessing(IfThenToSafeAccessInspection()) registerIntentionBasedProcessing(IfThenToElvisIntention()) - registerIntentionBasedProcessing(SimplifyNegatedBinaryExpressionIntention()) + registerInspectionBasedProcessing(SimplifyNegatedBinaryExpressionInspection()) registerInspectionBasedProcessing(ReplaceGetOrSetInspection()) registerIntentionBasedProcessing(AddOperatorModifierIntention()) registerIntentionBasedProcessing(ObjectLiteralToLambdaIntention()) diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/.inspection b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/.inspection new file mode 100644 index 00000000000..839a96b793c --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/.inspection @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.inspections.SimplifyNegatedBinaryExpressionInspection diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/equals.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/equals.kt new file mode 100644 index 00000000000..be75483ad69 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/equals.kt @@ -0,0 +1,4 @@ +// FIX: Simplify negated '==' expression to '!=' +fun test(n: Int) { + !(0 == 1) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/equals.kt.after b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/equals.kt.after new file mode 100644 index 00000000000..ae3fe949c8c --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/equals.kt.after @@ -0,0 +1,4 @@ +// FIX: Simplify negated '==' expression to '!=' +fun test(n: Int) { + 0 != 1 +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThan.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThan.kt new file mode 100644 index 00000000000..e59f13cb799 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThan.kt @@ -0,0 +1,4 @@ +// FIX: Simplify negated '>' expression to '<=' +fun test(n: Int) { + !(0 > 1) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThan.kt.after b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThan.kt.after new file mode 100644 index 00000000000..b12e93b4619 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThan.kt.after @@ -0,0 +1,4 @@ +// FIX: Simplify negated '>' expression to '<=' +fun test(n: Int) { + 0 <= 1 +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt new file mode 100644 index 00000000000..b9998fbd72a --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt @@ -0,0 +1,4 @@ +// FIX: Simplify negated '>=' expression to '<' +fun test(n: Int) { + !(0 >= 1) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt.after b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt.after new file mode 100644 index 00000000000..e1f9d13c132 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt.after @@ -0,0 +1,4 @@ +// FIX: Simplify negated '>=' expression to '<' +fun test(n: Int) { + 0 < 1 +} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/in.kt similarity index 69% rename from idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt rename to idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/in.kt index ab89ede2a84..f71e0a7ff3d 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/in.kt @@ -1,4 +1,4 @@ -// INTENTION_TEXT: Simplify negated 'in' expression to '!in' +// FIX: Simplify negated 'in' expression to '!in' class A(val e: Int) { operator fun contains(i: Int): Boolean = e == i } diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt.after b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/in.kt.after similarity index 67% rename from idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt.after rename to idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/in.kt.after index 4ec59f26966..3ddaf9c4861 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt.after +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/in.kt.after @@ -1,4 +1,4 @@ -// INTENTION_TEXT: Simplify negated 'in' expression to '!in' +// FIX: Simplify negated 'in' expression to '!in' class A(val e: Int) { operator fun contains(i: Int): Boolean = e == i } diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt similarity index 78% rename from idea/testData/intentions/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt rename to idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt index e59e1b4e621..b93236bbe4e 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none infix fun Int.lt(b: Int): Boolean = this < b fun test(n: Int) { !(1 lt 2) diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/expected.xml b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/expected.xml similarity index 62% rename from idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/expected.xml rename to idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/expected.xml index de9eac81433..e6a3192f012 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/expected.xml +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/expected.xml @@ -5,8 +5,8 @@ 3 light_idea_test_case - Simplify Negated Binary Expression - Simplify negated '!is' expression to 'is' + Negated boolean expression that can be simplified + Negated expression can be simplified @@ -14,8 +14,8 @@ 8 light_idea_test_case - Simplify Negated Binary Expression - Simplify negated '!in' expression to 'in' + Negated boolean expression that can be simplified + Negated expression can be simplified @@ -23,8 +23,8 @@ 3 light_idea_test_case - Simplify Negated Binary Expression - Simplify negated '!=' expression to '==' + Negated boolean expression that can be simplified + Negated expression can be simplified @@ -32,8 +32,8 @@ 3 light_idea_test_case - Simplify Negated Binary Expression - Simplify negated '<=' expression to '>' + Negated boolean expression that can be simplified + Negated expression can be simplified @@ -41,8 +41,8 @@ 3 light_idea_test_case - Simplify Negated Binary Expression - Simplify negated '<' expression to '>=' + Negated boolean expression that can be simplified + Negated expression can be simplified @@ -50,8 +50,8 @@ 3 light_idea_test_case - Simplify Negated Binary Expression - Simplify negated 'is' expression to '!is' + Negated boolean expression that can be simplified + Negated expression can be simplified @@ -59,8 +59,8 @@ 8 light_idea_test_case - Simplify Negated Binary Expression - Simplify negated 'in' expression to '!in' + Negated boolean expression that can be simplified + Negated expression can be simplified @@ -68,8 +68,8 @@ 3 light_idea_test_case - Simplify Negated Binary Expression - Simplify negated '>=' expression to '<' + Negated boolean expression that can be simplified + Negated expression can be simplified @@ -77,8 +77,8 @@ 3 light_idea_test_case - Simplify Negated Binary Expression - Simplify negated '>' expression to '<=' + Negated boolean expression that can be simplified + Negated expression can be simplified @@ -86,8 +86,8 @@ 3 light_idea_test_case - Simplify Negated Binary Expression - Simplify negated '==' expression to '!=' + Negated boolean expression that can be simplified + Negated expression can be simplified \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/inspections.test b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/inspections.test new file mode 100644 index 00000000000..4e2a25d43a3 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/inspections.test @@ -0,0 +1 @@ +// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.SimplifyNegatedBinaryExpressionInspection diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/is.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/is.kt new file mode 100644 index 00000000000..aae24581171 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/is.kt @@ -0,0 +1,4 @@ +// FIX: Simplify negated 'is' expression to '!is' +fun test(n: Int) { + !(0 is Int) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/is.kt.after b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/is.kt.after new file mode 100644 index 00000000000..08ca72e4e6f --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/is.kt.after @@ -0,0 +1,4 @@ +// FIX: Simplify negated 'is' expression to '!is' +fun test(n: Int) { + 0 !is Int +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThan.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThan.kt new file mode 100644 index 00000000000..4e798fe689a --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThan.kt @@ -0,0 +1,4 @@ +// FIX: Simplify negated '<' expression to '>=' +fun test(n: Int) { + !(0 < 1) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThan.kt.after b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThan.kt.after new file mode 100644 index 00000000000..1c4fa893cc9 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThan.kt.after @@ -0,0 +1,4 @@ +// FIX: Simplify negated '<' expression to '>=' +fun test(n: Int) { + 0 >= 1 +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThanOrEquals.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThanOrEquals.kt new file mode 100644 index 00000000000..b8ff0839d19 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThanOrEquals.kt @@ -0,0 +1,4 @@ +// FIX: Simplify negated '<=' expression to '>' +fun test(n: Int) { + !(0 <= 1) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThanOrEquals.kt.after b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThanOrEquals.kt.after new file mode 100644 index 00000000000..f6e15fa7d2d --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThanOrEquals.kt.after @@ -0,0 +1,4 @@ +// FIX: Simplify negated '<=' expression to '>' +fun test(n: Int) { + 0 > 1 +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notEquals.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notEquals.kt new file mode 100644 index 00000000000..a769cab4c83 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notEquals.kt @@ -0,0 +1,4 @@ +// FIX: Simplify negated '!=' expression to '==' +fun test(n: Int) { + !(0 != 1) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notEquals.kt.after b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notEquals.kt.after new file mode 100644 index 00000000000..df09f2a60ed --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notEquals.kt.after @@ -0,0 +1,4 @@ +// FIX: Simplify negated '!=' expression to '==' +fun test(n: Int) { + 0 == 1 +} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIn.kt similarity index 69% rename from idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt rename to idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIn.kt index 44a913ccfa5..1eebab4ba7c 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIn.kt @@ -1,4 +1,4 @@ -// INTENTION_TEXT: Simplify negated '!in' expression to 'in' +// FIX: Simplify negated '!in' expression to 'in' class A(val e: Int) { operator fun contains(i: Int): Boolean = e == i } diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt.after b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIn.kt.after similarity index 67% rename from idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt.after rename to idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIn.kt.after index f6867ae2852..98d9ada1495 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt.after +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIn.kt.after @@ -1,4 +1,4 @@ -// INTENTION_TEXT: Simplify negated '!in' expression to 'in' +// FIX: Simplify negated '!in' expression to 'in' class A(val e: Int) { operator fun contains(i: Int): Boolean = e == i } diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIs.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIs.kt new file mode 100644 index 00000000000..e90b4dfc910 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIs.kt @@ -0,0 +1,4 @@ +// FIX: Simplify negated '!is' expression to 'is' +fun test(n: Int) { + !(0 !is Int) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIs.kt.after b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIs.kt.after new file mode 100644 index 00000000000..5a68b4ab282 --- /dev/null +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIs.kt.after @@ -0,0 +1,4 @@ +// FIX: Simplify negated '!is' expression to 'is' +fun test(n: Int) { + 0 is Int +} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/simpleInvert.kt b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/simpleInvert.kt similarity index 60% rename from idea/testData/intentions/simplifyNegatedBinaryExpression/simpleInvert.kt rename to idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/simpleInvert.kt index 46f0c504048..993f79996b2 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/simpleInvert.kt +++ b/idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/simpleInvert.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none fun test(n: Int) { !true } \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/.intention b/idea/testData/intentions/simplifyNegatedBinaryExpression/.intention deleted file mode 100644 index 89819d4753e..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/.intention +++ /dev/null @@ -1 +0,0 @@ -org.jetbrains.kotlin.idea.intentions.SimplifyNegatedBinaryExpressionIntention diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/equals.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/equals.kt deleted file mode 100644 index 6c8342e1711..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/equals.kt +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '==' expression to '!=' -fun test(n: Int) { - !(0 == 1) -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/equals.kt.after b/idea/testData/intentions/simplifyNegatedBinaryExpression/equals.kt.after deleted file mode 100644 index 433463d6976..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/equals.kt.after +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '==' expression to '!=' -fun test(n: Int) { - 0 != 1 -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThan.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThan.kt deleted file mode 100644 index 053a1042c04..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThan.kt +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '>' expression to '<=' -fun test(n: Int) { - !(0 > 1) -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThan.kt.after b/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThan.kt.after deleted file mode 100644 index 0cc456fb2e9..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThan.kt.after +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '>' expression to '<=' -fun test(n: Int) { - 0 <= 1 -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt deleted file mode 100644 index 473cd495df9..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '>=' expression to '<' -fun test(n: Int) { - !(0 >= 1) -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt.after b/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt.after deleted file mode 100644 index 03f1a925600..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt.after +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '>=' expression to '<' -fun test(n: Int) { - 0 < 1 -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/inspections.test b/idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/inspections.test deleted file mode 100644 index cde81a4753e..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/inspections.test +++ /dev/null @@ -1 +0,0 @@ -// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.SimplifyNegatedBinaryExpressionInspection diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/is.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/is.kt deleted file mode 100644 index 57673a4939a..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/is.kt +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated 'is' expression to '!is' -fun test(n: Int) { - !(0 is Int) -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/is.kt.after b/idea/testData/intentions/simplifyNegatedBinaryExpression/is.kt.after deleted file mode 100644 index 0e23ca8f264..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/is.kt.after +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated 'is' expression to '!is' -fun test(n: Int) { - 0 !is Int -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThan.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThan.kt deleted file mode 100644 index 383fd03fc24..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThan.kt +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '<' expression to '>=' -fun test(n: Int) { - !(0 < 1) -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThan.kt.after b/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThan.kt.after deleted file mode 100644 index 2181eba637d..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThan.kt.after +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '<' expression to '>=' -fun test(n: Int) { - 0 >= 1 -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThanOrEquals.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThanOrEquals.kt deleted file mode 100644 index 45cffa1a785..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThanOrEquals.kt +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '<=' expression to '>' -fun test(n: Int) { - !(0 <= 1) -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThanOrEquals.kt.after b/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThanOrEquals.kt.after deleted file mode 100644 index 6d0d246accb..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/lessThanOrEquals.kt.after +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '<=' expression to '>' -fun test(n: Int) { - 0 > 1 -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/notEquals.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/notEquals.kt deleted file mode 100644 index 64795ce61c5..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/notEquals.kt +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '!=' expression to '==' -fun test(n: Int) { - !(0 != 1) -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/notEquals.kt.after b/idea/testData/intentions/simplifyNegatedBinaryExpression/notEquals.kt.after deleted file mode 100644 index 9e49cb44877..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/notEquals.kt.after +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '!=' expression to '==' -fun test(n: Int) { - 0 == 1 -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIs.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/notIs.kt deleted file mode 100644 index ac40c845584..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIs.kt +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '!is' expression to 'is' -fun test(n: Int) { - !(0 !is Int) -} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIs.kt.after b/idea/testData/intentions/simplifyNegatedBinaryExpression/notIs.kt.after deleted file mode 100644 index 361e7a30ec5..00000000000 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIs.kt.after +++ /dev/null @@ -1,4 +0,0 @@ -// INTENTION_TEXT: Simplify negated '!is' expression to 'is' -fun test(n: Int) { - 0 is Int -} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java index 6a2caab7286..dbea889ec07 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java @@ -85,12 +85,6 @@ public class InspectionTestGenerated extends AbstractInspectionTest { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeExplicitTypeArguments/inspectionData/inspections.test"); doTest(fileName); } - - @TestMetadata("simplifyNegatedBinaryExpression/inspectionData/inspections.test") - public void testSimplifyNegatedBinaryExpression_inspectionData_Inspections_test() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/inspections.test"); - doTest(fileName); - } } @TestMetadata("idea/testData/inspections") @@ -493,5 +487,11 @@ public class InspectionTestGenerated extends AbstractInspectionTest { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test"); doTest(fileName); } + + @TestMetadata("simplifyNegatedBinaryExpression/inspectionData/inspections.test") + public void testSimplifyNegatedBinaryExpression_inspectionData_Inspections_test() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inspectionData/inspections.test"); + doTest(fileName); + } } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index e1f018a6cbe..3ea40846d6d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -3516,6 +3516,87 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } + @TestMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SimplifyNegatedBinaryExpression extends AbstractLocalInspectionTest { + public void testAllFilesPresentInSimplifyNegatedBinaryExpression() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("equals.kt") + public void testEquals() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/equals.kt"); + doTest(fileName); + } + + @TestMetadata("greaterThan.kt") + public void testGreaterThan() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThan.kt"); + doTest(fileName); + } + + @TestMetadata("greaterThanOrEquals.kt") + public void testGreaterThanOrEquals() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt"); + doTest(fileName); + } + + @TestMetadata("in.kt") + public void testIn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/in.kt"); + doTest(fileName); + } + + @TestMetadata("inapplicableBinaryOperation.kt") + public void testInapplicableBinaryOperation() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt"); + doTest(fileName); + } + + @TestMetadata("is.kt") + public void testIs() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/is.kt"); + doTest(fileName); + } + + @TestMetadata("lessThan.kt") + public void testLessThan() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThan.kt"); + doTest(fileName); + } + + @TestMetadata("lessThanOrEquals.kt") + public void testLessThanOrEquals() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/lessThanOrEquals.kt"); + doTest(fileName); + } + + @TestMetadata("notEquals.kt") + public void testNotEquals() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notEquals.kt"); + doTest(fileName); + } + + @TestMetadata("notIn.kt") + public void testNotIn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIn.kt"); + doTest(fileName); + } + + @TestMetadata("notIs.kt") + public void testNotIs() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/notIs.kt"); + doTest(fileName); + } + + @TestMetadata("simpleInvert.kt") + public void testSimpleInvert() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/simplifyNegatedBinaryExpression/simpleInvert.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/inspectionsLocal/simplifyWhenWithBooleanConstantCondition") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index f595d62cfa4..9ebd7066555 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -14463,87 +14463,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { } } - @TestMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SimplifyNegatedBinaryExpression extends AbstractIntentionTest { - public void testAllFilesPresentInSimplifyNegatedBinaryExpression() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/simplifyNegatedBinaryExpression"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); - } - - @TestMetadata("equals.kt") - public void testEquals() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/equals.kt"); - doTest(fileName); - } - - @TestMetadata("greaterThan.kt") - public void testGreaterThan() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThan.kt"); - doTest(fileName); - } - - @TestMetadata("greaterThanOrEquals.kt") - public void testGreaterThanOrEquals() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/greaterThanOrEquals.kt"); - doTest(fileName); - } - - @TestMetadata("in.kt") - public void testIn() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt"); - doTest(fileName); - } - - @TestMetadata("inapplicableBinaryOperation.kt") - public void testInapplicableBinaryOperation() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt"); - doTest(fileName); - } - - @TestMetadata("is.kt") - public void testIs() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/is.kt"); - doTest(fileName); - } - - @TestMetadata("lessThan.kt") - public void testLessThan() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/lessThan.kt"); - doTest(fileName); - } - - @TestMetadata("lessThanOrEquals.kt") - public void testLessThanOrEquals() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/lessThanOrEquals.kt"); - doTest(fileName); - } - - @TestMetadata("notEquals.kt") - public void testNotEquals() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/notEquals.kt"); - doTest(fileName); - } - - @TestMetadata("notIn.kt") - public void testNotIn() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt"); - doTest(fileName); - } - - @TestMetadata("notIs.kt") - public void testNotIs() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/notIs.kt"); - doTest(fileName); - } - - @TestMetadata("simpleInvert.kt") - public void testSimpleInvert() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyNegatedBinaryExpression/simpleInvert.kt"); - doTest(fileName); - } - } - @TestMetadata("idea/testData/intentions/specifyExplicitLambdaSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)