diff --git a/idea/resources/META-INF/plugin-common.xml b/idea/resources/META-INF/plugin-common.xml index d17a769bbef..4f9cc8b09c3 100644 --- a/idea/resources/META-INF/plugin-common.xml +++ b/idea/resources/META-INF/plugin-common.xml @@ -1143,11 +1143,6 @@ Kotlin - - org.jetbrains.kotlin.idea.intentions.ConvertAssertToIfWithThrowIntention - Kotlin - - org.jetbrains.kotlin.idea.intentions.ConvertIfWithThrowToAssertIntention Kotlin diff --git a/idea/resources/intentionDescriptions/ConvertAssertToIfWithThrowIntention/after.kt.template b/idea/resources/intentionDescriptions/ConvertAssertToIfWithThrowIntention/after.kt.template deleted file mode 100644 index 2999e48a3ca..00000000000 --- a/idea/resources/intentionDescriptions/ConvertAssertToIfWithThrowIntention/after.kt.template +++ /dev/null @@ -1,5 +0,0 @@ -fun foo() { - if (!true) { - throw AssertionError("text") - } -} diff --git a/idea/resources/intentionDescriptions/ConvertAssertToIfWithThrowIntention/before.kt.template b/idea/resources/intentionDescriptions/ConvertAssertToIfWithThrowIntention/before.kt.template deleted file mode 100644 index 425fad76052..00000000000 --- a/idea/resources/intentionDescriptions/ConvertAssertToIfWithThrowIntention/before.kt.template +++ /dev/null @@ -1,3 +0,0 @@ -fun foo() { - assert(true, "text") -} \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ConvertAssertToIfWithThrowIntention/description.html b/idea/resources/intentionDescriptions/ConvertAssertToIfWithThrowIntention/description.html deleted file mode 100644 index 3aa6a714c94..00000000000 --- a/idea/resources/intentionDescriptions/ConvertAssertToIfWithThrowIntention/description.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This intention converts an assert into an if statement that throws an exception if the condition is false. - - \ 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 deleted file mode 100644 index 2f3e56818e3..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2010-2015 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.intentions - -import com.intellij.codeInsight.intention.LowPriorityAction -import com.intellij.openapi.editor.Editor -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall -import org.jetbrains.kotlin.idea.core.ShortenReferences -import org.jetbrains.kotlin.idea.core.replaced -import org.jetbrains.kotlin.idea.inspections.SimplifyNegatedBinaryExpressionInspection -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression -import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode - -class ConvertAssertToIfWithThrowIntention : SelfTargetingIntention(KtCallExpression::class.java, "Replace 'assert' with 'if' statement"), LowPriorityAction { - override fun isApplicableTo(element: KtCallExpression, caretOffset: Int): Boolean { - val callee = element.calleeExpression ?: return false - if (!callee.textRange.containsOffset(caretOffset)) return false - - val argumentSize = element.valueArguments.size - if (argumentSize !in 1..2) return false - val functionLiterals = element.lambdaArguments - if (functionLiterals.size > 1) return false - if (functionLiterals.size == 1 && argumentSize == 1) return false // "assert {...}" is incorrect - - val resolvedCall = element.resolveToCall() ?: return false - return DescriptorUtils.getFqName(resolvedCall.resultingDescriptor).asString() == "kotlin.assert" - } - - override fun applyTo(element: KtCallExpression, editor: Editor?) { - val args = element.valueArguments - val conditionText = args[0]?.getArgumentExpression()?.text ?: return - val functionLiteralArgument = element.lambdaArguments.singleOrNull() - val bindingContext = element.analyze(BodyResolveMode.PARTIAL_WITH_CFA) - val psiFactory = KtPsiFactory(element) - - val messageFunctionExpr = when { - args.size == 2 -> args[1]?.getArgumentExpression() ?: return - functionLiteralArgument != null -> functionLiteralArgument.getLambdaExpression() - else -> null - } - - val extractedMessageSingleExpr = (messageFunctionExpr as? KtLambdaExpression)?.let { extractMessageSingleExpression(it, bindingContext) } - - val messageIsFunction = extractedMessageSingleExpr == null && messageIsFunction(element, bindingContext) - val messageExpr = extractedMessageSingleExpr ?: messageFunctionExpr ?: psiFactory.createExpression("\"Assertion failed\"") - - val ifExpression = replaceWithIfThenThrowExpression(element) - - // shorten java.lang.AssertionError - ShortenReferences.DEFAULT.process(ifExpression.then!!) - - val ifCondition = ifExpression.condition as KtPrefixExpression - ifCondition.baseExpression!!.replace(psiFactory.createExpression(conditionText)) - - val thrownExpression = ((ifExpression.then as KtBlockExpression).statements.single() as KtThrowExpression).thrownExpression - val assertionErrorCall = thrownExpression as? KtCallExpression - ?: (thrownExpression as KtDotQualifiedExpression).selectorExpression as KtCallExpression - - val message = psiFactory.createExpression( - if (messageIsFunction && messageExpr is KtCallableReferenceExpression) { - messageExpr.callableReference.text + "()" - } - else if (messageIsFunction) { - messageExpr.text + "()" - } - else { - messageExpr.text - } - ) - assertionErrorCall.valueArguments.single().getArgumentExpression()!!.replace(message) - - simplifyConditionIfPossible(ifExpression, editor) - } - - private fun extractMessageSingleExpression(functionLiteral: KtLambdaExpression, bindingContext: BindingContext): KtExpression? { - return functionLiteral.bodyExpression?.statements?.singleOrNull()?.let { singleStatement -> - singleStatement.takeIf { it.isUsedAsExpression(bindingContext) } - } - } - - private fun messageIsFunction(callExpr: KtCallExpression, bindingContext: BindingContext): Boolean { - val resolvedCall = callExpr.getResolvedCall(bindingContext) ?: return false - val valParameters = resolvedCall.resultingDescriptor.valueParameters - return valParameters.size > 1 && !KotlinBuiltIns.isAny(valParameters[1].type) - } - - private fun simplifyConditionIfPossible(ifExpression: KtIfExpression, editor: Editor?) { - val condition = ifExpression.condition as KtPrefixExpression - val simplifier = SimplifyNegatedBinaryExpressionInspection() - if (simplifier.isApplicable(condition)) { - simplifier.applyTo(condition.operationReference, editor = editor) - } - } - - private fun replaceWithIfThenThrowExpression(original: KtCallExpression): KtIfExpression { - val replacement = KtPsiFactory(original).createExpression("if (!true) { throw kotlin.AssertionError(\"\") }") as KtIfExpression - val parent = original.parent - return (parent as? KtDotQualifiedExpression)?.replaced(replacement) ?: original.replaced(replacement) - } -} diff --git a/idea/testData/intentions/convertAssertToIf/.intention b/idea/testData/intentions/convertAssertToIf/.intention deleted file mode 100644 index 06a97bd6791..00000000000 --- a/idea/testData/intentions/convertAssertToIf/.intention +++ /dev/null @@ -1 +0,0 @@ -org.jetbrains.kotlin.idea.intentions.ConvertAssertToIfWithThrowIntention diff --git a/idea/testData/intentions/convertAssertToIf/assertErrorOverloaded.kt b/idea/testData/intentions/convertAssertToIf/assertErrorOverloaded.kt deleted file mode 100644 index 26c165825ee..00000000000 --- a/idea/testData/intentions/convertAssertToIf/assertErrorOverloaded.kt +++ /dev/null @@ -1,9 +0,0 @@ -package a - -fun foo() { - assert(true, { "text" }) -} - -class AssertionError - -// WITH_RUNTIME diff --git a/idea/testData/intentions/convertAssertToIf/assertErrorOverloaded.kt.after b/idea/testData/intentions/convertAssertToIf/assertErrorOverloaded.kt.after deleted file mode 100644 index f4ee4d6537d..00000000000 --- a/idea/testData/intentions/convertAssertToIf/assertErrorOverloaded.kt.after +++ /dev/null @@ -1,11 +0,0 @@ -package a - -fun foo() { - if (!true) { - throw AssertionError("text") - } -} - -class AssertionError - -// WITH_RUNTIME diff --git a/idea/testData/intentions/convertAssertToIf/booleanCondition.kt b/idea/testData/intentions/convertAssertToIf/booleanCondition.kt deleted file mode 100644 index abee093a6cc..00000000000 --- a/idea/testData/intentions/convertAssertToIf/booleanCondition.kt +++ /dev/null @@ -1,4 +0,0 @@ -// WITH_RUNTIME -fun foo() { - assert(true && false, { "text" }) -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/booleanCondition.kt.after b/idea/testData/intentions/convertAssertToIf/booleanCondition.kt.after deleted file mode 100644 index 887d6df9ed0..00000000000 --- a/idea/testData/intentions/convertAssertToIf/booleanCondition.kt.after +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (!(true && false)) { - throw AssertionError("text") - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified.kt b/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified.kt deleted file mode 100644 index 7cdbfba9a17..00000000000 --- a/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified.kt +++ /dev/null @@ -1,4 +0,0 @@ -// WITH_RUNTIME -fun foo() { - assert(1 > 0) { "text" } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified.kt.after b/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified.kt.after deleted file mode 100644 index 4bcf747a4c8..00000000000 --- a/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified.kt.after +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (1 <= 0) { - throw AssertionError("text") - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified2.kt b/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified2.kt deleted file mode 100644 index e7b6acde349..00000000000 --- a/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified2.kt +++ /dev/null @@ -1,4 +0,0 @@ -// WITH_RUNTIME -fun foo() { - assert(0 != 1) { "text" } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified2.kt.after b/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified2.kt.after deleted file mode 100644 index d68ed200c02..00000000000 --- a/idea/testData/intentions/convertAssertToIf/booleanConditionSimplified2.kt.after +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (0 == 1) { - throw AssertionError("text") - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/booleanConditionWithVariables.kt b/idea/testData/intentions/convertAssertToIf/booleanConditionWithVariables.kt deleted file mode 100644 index 4e706b88e2f..00000000000 --- a/idea/testData/intentions/convertAssertToIf/booleanConditionWithVariables.kt +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - val x = true - val y = false - assert(x || y) { "text" } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/booleanConditionWithVariables.kt.after b/idea/testData/intentions/convertAssertToIf/booleanConditionWithVariables.kt.after deleted file mode 100644 index c4b74c42164..00000000000 --- a/idea/testData/intentions/convertAssertToIf/booleanConditionWithVariables.kt.after +++ /dev/null @@ -1,8 +0,0 @@ -// WITH_RUNTIME -fun foo() { - val x = true - val y = false - if (!(x || y)) { - throw AssertionError("text") - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/doNotShortenReferenceInsideMessage.kt b/idea/testData/intentions/convertAssertToIf/doNotShortenReferenceInsideMessage.kt deleted file mode 100644 index 1067fade341..00000000000 --- a/idea/testData/intentions/convertAssertToIf/doNotShortenReferenceInsideMessage.kt +++ /dev/null @@ -1,5 +0,0 @@ -fun main(args: Array) { - assert(false) { "mess" as kotlin.String } -} - -// WITH_RUNTIME \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/doNotShortenReferenceInsideMessage.kt.after b/idea/testData/intentions/convertAssertToIf/doNotShortenReferenceInsideMessage.kt.after deleted file mode 100644 index 3fec6346b14..00000000000 --- a/idea/testData/intentions/convertAssertToIf/doNotShortenReferenceInsideMessage.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -fun main(args: Array) { - if (!false) { - throw AssertionError("mess" as kotlin.String) - } -} - -// WITH_RUNTIME \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/dotQualifiedCall.kt b/idea/testData/intentions/convertAssertToIf/dotQualifiedCall.kt deleted file mode 100644 index 0f7f5ecad34..00000000000 --- a/idea/testData/intentions/convertAssertToIf/dotQualifiedCall.kt +++ /dev/null @@ -1,4 +0,0 @@ -// WITH_RUNTIME -fun foo() { - kotlin.assert(true) {"text"} -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/dotQualifiedCall.kt.after b/idea/testData/intentions/convertAssertToIf/dotQualifiedCall.kt.after deleted file mode 100644 index e91f674a0b9..00000000000 --- a/idea/testData/intentions/convertAssertToIf/dotQualifiedCall.kt.after +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (!true) { - throw AssertionError("text") - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/functionCallCondition.kt b/idea/testData/intentions/convertAssertToIf/functionCallCondition.kt deleted file mode 100644 index 702dd734733..00000000000 --- a/idea/testData/intentions/convertAssertToIf/functionCallCondition.kt +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - assert(bar()) { "text" } -} - -fun bar(): Boolean = true \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/functionCallCondition.kt.after b/idea/testData/intentions/convertAssertToIf/functionCallCondition.kt.after deleted file mode 100644 index 453897bc474..00000000000 --- a/idea/testData/intentions/convertAssertToIf/functionCallCondition.kt.after +++ /dev/null @@ -1,8 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (!bar()) { - throw AssertionError("text") - } -} - -fun bar(): Boolean = true \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/functionMessageInsideParentheses.kt b/idea/testData/intentions/convertAssertToIf/functionMessageInsideParentheses.kt deleted file mode 100644 index c645cec6f06..00000000000 --- a/idea/testData/intentions/convertAssertToIf/functionMessageInsideParentheses.kt +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - assert(true, ::message) -} - -fun message(): String = "text" \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/functionMessageInsideParentheses.kt.after b/idea/testData/intentions/convertAssertToIf/functionMessageInsideParentheses.kt.after deleted file mode 100644 index 0f7d3ac1749..00000000000 --- a/idea/testData/intentions/convertAssertToIf/functionMessageInsideParentheses.kt.after +++ /dev/null @@ -1,8 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (!true) { - throw AssertionError(message()) - } -} - -fun message(): String = "text" \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/inapplicableAssertOverloaded.kt b/idea/testData/intentions/convertAssertToIf/inapplicableAssertOverloaded.kt deleted file mode 100644 index 490f0ecafdb..00000000000 --- a/idea/testData/intentions/convertAssertToIf/inapplicableAssertOverloaded.kt +++ /dev/null @@ -1,7 +0,0 @@ -// IS_APPLICABLE: false -// WITH_RUNTIME -fun foo() { - assert(true, "") -} - -fun assert(b: Boolean, s: String) {} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/inapplicableAssertOverloadedWithPackage.kt b/idea/testData/intentions/convertAssertToIf/inapplicableAssertOverloadedWithPackage.kt deleted file mode 100644 index 4799dd5673d..00000000000 --- a/idea/testData/intentions/convertAssertToIf/inapplicableAssertOverloadedWithPackage.kt +++ /dev/null @@ -1,9 +0,0 @@ -// IS_APPLICABLE: false -// WITH_RUNTIME -package pr442.kotlin - -fun foo() { - assert(true, "") -} - -fun assert(b: Boolean, s: String) {} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/inapplicableNoCondition.kt b/idea/testData/intentions/convertAssertToIf/inapplicableNoCondition.kt deleted file mode 100644 index dce348fe369..00000000000 --- a/idea/testData/intentions/convertAssertToIf/inapplicableNoCondition.kt +++ /dev/null @@ -1,7 +0,0 @@ -// IS_APPLICABLE: false -// WITH_RUNTIME -// ERROR: None of the following functions can be called with the arguments supplied:
@InlineOnly public inline fun assert(value: Boolean): Unit defined in kotlin
@InlineOnly public inline fun assert(value: Boolean, lazyMessage: () -> Any): Unit defined in kotlin - -fun foo() { - assert() -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/lambdaMessageInsideParentheses.kt b/idea/testData/intentions/convertAssertToIf/lambdaMessageInsideParentheses.kt deleted file mode 100644 index 31ac7316873..00000000000 --- a/idea/testData/intentions/convertAssertToIf/lambdaMessageInsideParentheses.kt +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - assert(true, { - if (true) "text" else return - }) -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/lambdaMessageInsideParentheses.kt.after b/idea/testData/intentions/convertAssertToIf/lambdaMessageInsideParentheses.kt.after deleted file mode 100644 index 42022406dfe..00000000000 --- a/idea/testData/intentions/convertAssertToIf/lambdaMessageInsideParentheses.kt.after +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (!true) { - throw AssertionError(if (true) "text" else return) - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/lambdaMessageOutsideParentheses.kt b/idea/testData/intentions/convertAssertToIf/lambdaMessageOutsideParentheses.kt deleted file mode 100644 index 488d43c09f1..00000000000 --- a/idea/testData/intentions/convertAssertToIf/lambdaMessageOutsideParentheses.kt +++ /dev/null @@ -1,8 +0,0 @@ -// WITH_RUNTIME -// SKIP_ERRORS_AFTER -// TODO: 'return' is not allowed here -fun foo() { - assert(true) { - return - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/lambdaMessageOutsideParentheses.kt.after b/idea/testData/intentions/convertAssertToIf/lambdaMessageOutsideParentheses.kt.after deleted file mode 100644 index 80f6055d1cc..00000000000 --- a/idea/testData/intentions/convertAssertToIf/lambdaMessageOutsideParentheses.kt.after +++ /dev/null @@ -1,10 +0,0 @@ -// WITH_RUNTIME -// SKIP_ERRORS_AFTER -// TODO: 'return' is not allowed here -fun foo() { - if (!true) { - throw AssertionError({ - return - }()) - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageInsideParentheses.kt b/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageInsideParentheses.kt deleted file mode 100644 index 0bf302eef5c..00000000000 --- a/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageInsideParentheses.kt +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME -fun foo() { - assert(true, { - val value = 1 - "text and $value" - }) -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageInsideParentheses.kt.after b/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageInsideParentheses.kt.after deleted file mode 100644 index fdeac466960..00000000000 --- a/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageInsideParentheses.kt.after +++ /dev/null @@ -1,9 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (!true) { - throw AssertionError({ - val value = 1 - "text and $value" - }()) - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageOutsideParentheses.kt b/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageOutsideParentheses.kt deleted file mode 100644 index 9d2cf2ca7fe..00000000000 --- a/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageOutsideParentheses.kt +++ /dev/null @@ -1,9 +0,0 @@ -// WITH_RUNTIME -// SKIP_ERRORS_AFTER -// TODO: 'return' is not allowed here -fun foo() { - assert(true) { - if (false) return - "text" - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageOutsideParentheses.kt.after b/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageOutsideParentheses.kt.after deleted file mode 100644 index 8a8ddcc8527..00000000000 --- a/idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageOutsideParentheses.kt.after +++ /dev/null @@ -1,11 +0,0 @@ -// WITH_RUNTIME -// SKIP_ERRORS_AFTER -// TODO: 'return' is not allowed here -fun foo() { - if (!true) { - throw AssertionError({ - if (false) return - "text" - }()) - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/lambdaVariable.kt b/idea/testData/intentions/convertAssertToIf/lambdaVariable.kt deleted file mode 100644 index 65b7740e37d..00000000000 --- a/idea/testData/intentions/convertAssertToIf/lambdaVariable.kt +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_RUNTIME -fun foo() { - val f = { "text" } - assert(true, f) -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/lambdaVariable.kt.after b/idea/testData/intentions/convertAssertToIf/lambdaVariable.kt.after deleted file mode 100644 index e42d35854b8..00000000000 --- a/idea/testData/intentions/convertAssertToIf/lambdaVariable.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME -fun foo() { - val f = { "text" } - if (!true) { - throw AssertionError(f()) - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/noMessage.kt b/idea/testData/intentions/convertAssertToIf/noMessage.kt deleted file mode 100644 index ae77fe1429c..00000000000 --- a/idea/testData/intentions/convertAssertToIf/noMessage.kt +++ /dev/null @@ -1,4 +0,0 @@ -// WITH_RUNTIME -fun foo() { - assert(true) -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/noMessage.kt.after b/idea/testData/intentions/convertAssertToIf/noMessage.kt.after deleted file mode 100644 index 6713445b89b..00000000000 --- a/idea/testData/intentions/convertAssertToIf/noMessage.kt.after +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (!true) { - throw AssertionError("Assertion failed") - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/parenthesizedCondition.kt b/idea/testData/intentions/convertAssertToIf/parenthesizedCondition.kt deleted file mode 100644 index d61786133b2..00000000000 --- a/idea/testData/intentions/convertAssertToIf/parenthesizedCondition.kt +++ /dev/null @@ -1,4 +0,0 @@ -// WITH_RUNTIME -fun foo() { - assert((true && false)) { "text" } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/parenthesizedCondition.kt.after b/idea/testData/intentions/convertAssertToIf/parenthesizedCondition.kt.after deleted file mode 100644 index 887d6df9ed0..00000000000 --- a/idea/testData/intentions/convertAssertToIf/parenthesizedCondition.kt.after +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (!(true && false)) { - throw AssertionError("text") - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/simpleConvert.kt b/idea/testData/intentions/convertAssertToIf/simpleConvert.kt deleted file mode 100644 index 0939757b318..00000000000 --- a/idea/testData/intentions/convertAssertToIf/simpleConvert.kt +++ /dev/null @@ -1,4 +0,0 @@ -// WITH_RUNTIME -fun foo() { - assert(true) { "text" } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/simpleConvert.kt.after b/idea/testData/intentions/convertAssertToIf/simpleConvert.kt.after deleted file mode 100644 index e91f674a0b9..00000000000 --- a/idea/testData/intentions/convertAssertToIf/simpleConvert.kt.after +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -fun foo() { - if (!true) { - throw AssertionError("text") - } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/stringVariable.kt b/idea/testData/intentions/convertAssertToIf/stringVariable.kt deleted file mode 100644 index 2b83ee77e35..00000000000 --- a/idea/testData/intentions/convertAssertToIf/stringVariable.kt +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_RUNTIME -fun foo() { - val f = "text" - assert(true) { f } -} \ No newline at end of file diff --git a/idea/testData/intentions/convertAssertToIf/stringVariable.kt.after b/idea/testData/intentions/convertAssertToIf/stringVariable.kt.after deleted file mode 100644 index cb1b3cf9022..00000000000 --- a/idea/testData/intentions/convertAssertToIf/stringVariable.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME -fun foo() { - val f = "text" - if (!true) { - throw AssertionError(f) - } -} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 1f7ae7cfefd..4f5e3667ee6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -4651,124 +4651,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { } } - @TestMetadata("idea/testData/intentions/convertAssertToIf") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ConvertAssertToIf extends AbstractIntentionTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); - } - - public void testAllFilesPresentInConvertAssertToIf() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/convertAssertToIf"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); - } - - @TestMetadata("assertErrorOverloaded.kt") - public void testAssertErrorOverloaded() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/assertErrorOverloaded.kt"); - } - - @TestMetadata("booleanCondition.kt") - public void testBooleanCondition() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/booleanCondition.kt"); - } - - @TestMetadata("booleanConditionSimplified.kt") - public void testBooleanConditionSimplified() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/booleanConditionSimplified.kt"); - } - - @TestMetadata("booleanConditionSimplified2.kt") - public void testBooleanConditionSimplified2() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/booleanConditionSimplified2.kt"); - } - - @TestMetadata("booleanConditionWithVariables.kt") - public void testBooleanConditionWithVariables() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/booleanConditionWithVariables.kt"); - } - - @TestMetadata("doNotShortenReferenceInsideMessage.kt") - public void testDoNotShortenReferenceInsideMessage() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/doNotShortenReferenceInsideMessage.kt"); - } - - @TestMetadata("dotQualifiedCall.kt") - public void testDotQualifiedCall() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/dotQualifiedCall.kt"); - } - - @TestMetadata("functionCallCondition.kt") - public void testFunctionCallCondition() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/functionCallCondition.kt"); - } - - @TestMetadata("functionMessageInsideParentheses.kt") - public void testFunctionMessageInsideParentheses() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/functionMessageInsideParentheses.kt"); - } - - @TestMetadata("inapplicableAssertOverloaded.kt") - public void testInapplicableAssertOverloaded() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/inapplicableAssertOverloaded.kt"); - } - - @TestMetadata("inapplicableAssertOverloadedWithPackage.kt") - public void testInapplicableAssertOverloadedWithPackage() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/inapplicableAssertOverloadedWithPackage.kt"); - } - - @TestMetadata("inapplicableNoCondition.kt") - public void testInapplicableNoCondition() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/inapplicableNoCondition.kt"); - } - - @TestMetadata("lambdaMessageInsideParentheses.kt") - public void testLambdaMessageInsideParentheses() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/lambdaMessageInsideParentheses.kt"); - } - - @TestMetadata("lambdaMessageOutsideParentheses.kt") - public void testLambdaMessageOutsideParentheses() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/lambdaMessageOutsideParentheses.kt"); - } - - @TestMetadata("lambdaMultiStatementMessageInsideParentheses.kt") - public void testLambdaMultiStatementMessageInsideParentheses() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageInsideParentheses.kt"); - } - - @TestMetadata("lambdaMultiStatementMessageOutsideParentheses.kt") - public void testLambdaMultiStatementMessageOutsideParentheses() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageOutsideParentheses.kt"); - } - - @TestMetadata("lambdaVariable.kt") - public void testLambdaVariable() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/lambdaVariable.kt"); - } - - @TestMetadata("noMessage.kt") - public void testNoMessage() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/noMessage.kt"); - } - - @TestMetadata("parenthesizedCondition.kt") - public void testParenthesizedCondition() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/parenthesizedCondition.kt"); - } - - @TestMetadata("simpleConvert.kt") - public void testSimpleConvert() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/simpleConvert.kt"); - } - - @TestMetadata("stringVariable.kt") - public void testStringVariable() throws Exception { - runTest("idea/testData/intentions/convertAssertToIf/stringVariable.kt"); - } - } - @TestMetadata("idea/testData/intentions/convertBinaryExpressionWithDemorgansLaw") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)