From 8e0bbe7d4a6983fcb522fc107245e7b11c6291f4 Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Mon, 17 Jun 2019 19:03:01 +0700 Subject: [PATCH] Convert ReplaceSingleLineLetIntention to inspection & decrease severity to INFORMATION #KT-32010 Fixed --- idea/resources/META-INF/plugin-common.xml | 9 +- .../after.kt.template | 1 - .../before.kt.template | 1 - .../description.html | 5 - .../ReplaceSingleLineLetInspection.kt | 207 +++++++++++ .../ReplaceSingleLineLetIntention.kt | 214 ------------ .../intentions/SafeAccessToIfThenIntention.kt | 8 +- .../replaceSingleLineLet/.inspection | 2 +- .../replaceSingleLineLet}/assignment.kt | 2 +- .../replaceSingleLineLet}/binarySafeCall.kt | 2 +- .../callChainWithLineBreak.kt | 2 +- .../callChainWithLineBreak.kt.after | 7 + .../replaceSingleLineLet}/comparisons.kt | 2 +- .../destructuringDeclaration.kt | 0 .../destructuringDeclaration.kt.after | 0 .../destructuringDeclaration2.kt | 0 .../destructuringDeclaration2.kt.after | 0 .../destructuringDeclaration3.kt | 2 +- .../destructuringDeclaration4.kt | 2 +- .../destructuringDeclaration5.kt | 2 +- .../dotWithComparison.kt | 2 +- .../replaceSingleLineLet}/functionCall1.kt | 0 .../functionCall1.kt.after | 0 .../replaceSingleLineLet}/functionCall2.kt | 2 +- .../functionCall2.kt.after | 0 .../replaceSingleLineLet}/functionCall3.kt | 0 .../functionCall3.kt.after | 0 .../replaceSingleLineLet}/functionCall4.kt | 0 .../functionCall4.kt.after | 0 .../replaceSingleLineLet}/functionCall5.kt | 0 .../functionCall5.kt.after | 0 .../replaceSingleLineLet}/functionCall6.kt | 0 .../functionCall6.kt.after | 0 .../replaceSingleLineLet}/functionCall7.kt | 2 +- .../functionCallInExtension.kt | 0 .../functionCallInExtension.kt.after | 0 .../functionCallOnSafeCall.kt | 2 +- .../functionInVariableCall.kt | 2 +- .../functionInVariableInvokeCall.kt | 0 .../functionInVariableInvokeCall.kt.after | 0 .../replaceSingleLineLet}/in.kt | 2 +- .../replaceSingleLineLet}/in.kt.after | 2 +- .../inWithMultipleParam.kt | 2 +- .../replaceSingleLineLet}/inWithRange.kt | 2 +- .../inWithRange.kt.after | 2 +- .../inWithRangeMultipleParam.kt | 2 +- .../replaceSingleLineLet}/invokeCall.kt | 0 .../replaceSingleLineLet}/invokeCall.kt.after | 0 .../replaceSingleLineLet}/invokeCall2.kt | 0 .../invokeCall2.kt.after | 0 .../replaceSingleLineLet}/invokeCall3.kt | 0 .../invokeCall3.kt.after | 0 .../replaceSingleLineLet}/invokeCall4.kt | 2 +- .../replaceSingleLineLet}/invokeCall5.kt | 2 +- .../lambdaWithBinaryExpression.kt | 2 +- .../lambdaWithBinaryExpression2.kt | 2 +- .../replaceSingleLineLet}/let.kt | 6 +- .../replaceSingleLineLet}/let.kt.after | 2 +- .../replaceSingleLineLet}/letMultipleLines.kt | 2 +- .../replaceSingleLineLet/letNoSafeCall.kt | 9 + .../letNoSafeCall.kt.after | 2 +- .../letNotUseParameterReceiver.kt | 2 +- .../letNotUseReceiver.kt | 2 +- .../replaceSingleLineLet}/letUseIt.kt | 2 +- .../letUseItAsParamWithBinaryExpression.kt | 2 +- .../letUseItWithBinaryExpression.kt | 2 +- .../letUseItWithBinaryExpression2.kt | 2 +- .../letUseItWithMultipleMethodCall1.kt | 2 +- .../letUseItWithMultipleMethodCall2.kt | 2 +- .../letUseItWithMultipleMethodCall3.kt | 2 +- .../replaceSingleLineLet}/letUseParameter.kt | 2 +- .../letWithBinaryExpression.kt | 2 +- .../letWithBinaryExpression.kt.after | 2 +- .../letWithMethodCall.kt | 6 +- .../letWithMethodCall.kt.after | 2 +- .../letWithMultipleMethodCall.kt | 9 + .../letWithMultipleMethodCall.kt.after | 2 +- .../replaceSingleLineLet}/letWithParameter.kt | 6 +- .../letWithParameter.kt.after | 2 +- .../letWithSimpleBinaryExpression.kt | 2 +- .../letWithSimpleBinaryExpression.kt.after | 2 +- .../letWithThisBinaryExpression.kt | 2 +- .../letWithThisBinaryExpression.kt.after | 2 +- .../letWithThisShortBinaryExpression.kt | 2 +- .../letWithThisShortBinaryExpression.kt.after | 2 +- .../replaceSingleLineLet/longCallChain.kt | 2 +- .../longCallChain.kt.after | 6 + .../replaceSingleLineLet}/multipleReceiver.kt | 2 +- .../multipleReceiver2.kt | 2 +- .../multipleReceiver3.kt | 2 +- .../replaceSingleLineLet}/multipleUsages.kt | 2 +- .../replaceSingleLineLet}/plusNullable.kt | 2 +- .../receiverWithLambda.kt | 2 +- .../receiverWithLambda2.kt | 2 +- .../replaceSingleLineLet}/sameLets.kt | 6 +- .../replaceSingleLineLet}/sameLets.kt.after | 2 +- .../replaceSingleLineLet}/smartCastInBody.kt | 2 +- .../replaceSingleLineLet}/this.kt | 2 +- .../replaceSingleLineLet}/this.kt.after | 2 +- .../replaceSingleLineLet}/thisShort.kt | 2 +- .../replaceSingleLineLet}/thisShort.kt.after | 2 +- .../replaceSingleLineLet}/typeChecks.kt | 2 +- .../replaceSingleLineLetIntention/.intention | 1 - .../letNoSafeCall.kt | 9 - .../letWithMultipleMethodCall.kt | 9 - .../LocalInspectionTestGenerated.java | 315 +++++++++++++++++ .../intentions/IntentionTestGenerated.java | 328 ------------------ 107 files changed, 633 insertions(+), 653 deletions(-) delete mode 100644 idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/after.kt.template delete mode 100644 idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/before.kt.template delete mode 100644 idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/description.html create mode 100644 idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceSingleLineLetInspection.kt delete mode 100644 idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/assignment.kt (85%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/binarySafeCall.kt (74%) create mode 100644 idea/testData/inspectionsLocal/replaceSingleLineLet/callChainWithLineBreak.kt.after rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/comparisons.kt (80%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/destructuringDeclaration.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/destructuringDeclaration.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/destructuringDeclaration2.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/destructuringDeclaration2.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/destructuringDeclaration3.kt (82%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/destructuringDeclaration4.kt (77%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/destructuringDeclaration5.kt (76%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/dotWithComparison.kt (83%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall1.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall1.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall2.kt (73%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall2.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall3.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall3.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall4.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall4.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall5.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall5.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall6.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall6.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCall7.kt (84%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCallInExtension.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCallInExtension.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionCallOnSafeCall.kt (85%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionInVariableCall.kt (80%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionInVariableInvokeCall.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/functionInVariableInvokeCall.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/in.kt (81%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/in.kt.after (78%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/inWithMultipleParam.kt (82%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/inWithRange.kt (82%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/inWithRange.kt.after (79%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/inWithRangeMultipleParam.kt (82%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/invokeCall.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/invokeCall.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/invokeCall2.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/invokeCall2.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/invokeCall3.kt (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/invokeCall3.kt.after (100%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/invokeCall4.kt (83%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/invokeCall5.kt (82%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/lambdaWithBinaryExpression.kt (81%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/lambdaWithBinaryExpression2.kt (82%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/let.kt (50%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/let.kt.after (76%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letMultipleLines.kt (83%) create mode 100644 idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letNoSafeCall.kt.after (75%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letNotUseParameterReceiver.kt (83%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letNotUseReceiver.kt (81%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letUseIt.kt (81%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letUseItAsParamWithBinaryExpression.kt (76%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letUseItWithBinaryExpression.kt (75%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letUseItWithBinaryExpression2.kt (76%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letUseItWithMultipleMethodCall1.kt (83%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letUseItWithMultipleMethodCall2.kt (83%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letUseItWithMultipleMethodCall3.kt (83%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letUseParameter.kt (83%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithBinaryExpression.kt (74%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithBinaryExpression.kt.after (67%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithMethodCall.kt (50%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithMethodCall.kt.after (76%) create mode 100644 idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithMultipleMethodCall.kt.after (79%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithParameter.kt (55%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithParameter.kt.after (76%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithSimpleBinaryExpression.kt (71%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithSimpleBinaryExpression.kt.after (64%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithThisBinaryExpression.kt (74%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithThisBinaryExpression.kt.after (67%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithThisShortBinaryExpression.kt (72%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/letWithThisShortBinaryExpression.kt.after (67%) create mode 100644 idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt.after rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/multipleReceiver.kt (81%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/multipleReceiver2.kt (82%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/multipleReceiver3.kt (79%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/multipleUsages.kt (84%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/plusNullable.kt (77%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/receiverWithLambda.kt (80%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/receiverWithLambda2.kt (91%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/sameLets.kt (55%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/sameLets.kt.after (83%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/smartCastInBody.kt (89%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/this.kt (79%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/this.kt.after (75%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/thisShort.kt (77%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/thisShort.kt.after (72%) rename idea/testData/{intentions/replaceSingleLineLetIntention => inspectionsLocal/replaceSingleLineLet}/typeChecks.kt (83%) delete mode 100644 idea/testData/intentions/replaceSingleLineLetIntention/.intention delete mode 100644 idea/testData/intentions/replaceSingleLineLetIntention/letNoSafeCall.kt delete mode 100644 idea/testData/intentions/replaceSingleLineLetIntention/letWithMultipleMethodCall.kt diff --git a/idea/resources/META-INF/plugin-common.xml b/idea/resources/META-INF/plugin-common.xml index 829d4f918ed..da36b94ce5a 100644 --- a/idea/resources/META-INF/plugin-common.xml +++ b/idea/resources/META-INF/plugin-common.xml @@ -1349,11 +1349,6 @@ Kotlin - - org.jetbrains.kotlin.idea.intentions.ReplaceSingleLineLetIntention - Kotlin - - org.jetbrains.kotlin.idea.intentions.copyConcatenatedStringToClipboard.CopyConcatenatedStringToClipboardIntention Kotlin @@ -2238,12 +2233,12 @@ language="kotlin" /> - diff --git a/idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/after.kt.template b/idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/after.kt.template deleted file mode 100644 index d75d12fb427..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/after.kt.template +++ /dev/null @@ -1 +0,0 @@ -text?.length diff --git a/idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/before.kt.template b/idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/before.kt.template deleted file mode 100644 index d2e7890d189..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/before.kt.template +++ /dev/null @@ -1 +0,0 @@ -text?.let { it.length } diff --git a/idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/description.html b/idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/description.html deleted file mode 100644 index 4cb084dc21a..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceSingleLineLetIntention/description.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This intention removes a redundant let call when it includes only one call with a lambda parameter as a receiver. - - diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceSingleLineLetInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceSingleLineLetInspection.kt new file mode 100644 index 00000000000..fc76b2c41dd --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceSingleLineLetInspection.kt @@ -0,0 +1,207 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.inspections + +import com.intellij.codeInspection.ProblemHighlightType +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall +import org.jetbrains.kotlin.idea.core.replaced +import org.jetbrains.kotlin.idea.intentions.* +import org.jetbrains.kotlin.idea.intentions.branchedTransformations.lineCount +import org.jetbrains.kotlin.idea.util.textRangeIn +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType +import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType +import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector +import org.jetbrains.kotlin.psi.psiUtil.startOffset +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.bindingContextUtil.getReferenceTargets +import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall +import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode + +class ReplaceSingleLineLetInspection : AbstractApplicabilityBasedInspection( + KtCallExpression::class.java +) { + override fun inspectionText(element: KtCallExpression) = "Replace single line .let" + + override fun inspectionHighlightRangeInElement(element: KtCallExpression) = element.calleeExpression?.textRangeIn(element) + + override fun inspectionHighlightType(element: KtCallExpression): ProblemHighlightType = if (isSingleLine(element)) + ProblemHighlightType.GENERIC_ERROR_OR_WARNING + else + ProblemHighlightType.INFORMATION + + override val defaultFixText = "Remove redundant '.let' call" + + override fun isApplicable(element: KtCallExpression): Boolean { + if (!element.isLetMethodCall()) return false + val lambdaExpression = element.lambdaArguments.firstOrNull()?.getLambdaExpression() ?: return false + val parameterName = lambdaExpression.getParameterName() ?: return false + + return when (val bodyExpression = lambdaExpression.bodyExpression?.children?.singleOrNull() ?: return false) { + is KtBinaryExpression -> + element.parent !is KtSafeQualifiedExpression && bodyExpression.isApplicable(parameterName) + is KtDotQualifiedExpression -> + bodyExpression.isApplicable(parameterName) + is KtCallExpression -> + if (element.parent is KtSafeQualifiedExpression) { + false + } else { + val count = lambdaExpression.functionLiteral.valueParameterReferences(bodyExpression).count() + val destructuringDeclaration = lambdaExpression.functionLiteral.valueParameters.firstOrNull()?.destructuringDeclaration + count == 0 || (count == 1 && destructuringDeclaration == null) + } + else -> + false + } + } + + override fun applyTo(element: KtCallExpression, project: Project, editor: Editor?) { + val lambdaExpression = element.lambdaArguments.firstOrNull()?.getLambdaExpression() ?: return + when (val bodyExpression = lambdaExpression.bodyExpression?.children?.singleOrNull() ?: return) { + is KtDotQualifiedExpression -> bodyExpression.applyTo(element) + is KtBinaryExpression -> bodyExpression.applyTo(element) + is KtCallExpression -> bodyExpression.applyTo(element, lambdaExpression.functionLiteral, editor) + } + } +} + +private fun KtBinaryExpression.applyTo(element: KtCallExpression) { + val left = left ?: return + val factory = KtPsiFactory(element.project) + when (val parent = element.parent) { + is KtQualifiedExpression -> { + val receiver = parent.receiverExpression + val newLeft = when (left) { + is KtDotQualifiedExpression -> left.replaceFirstReceiver(factory, receiver, parent is KtSafeQualifiedExpression) + else -> receiver + } + val newExpression = factory.createExpressionByPattern("$0 $1 $2", newLeft, operationReference, right!!) + parent.replace(newExpression) + } + else -> { + val newLeft = when (left) { + is KtDotQualifiedExpression -> left.deleteFirstReceiver() + else -> factory.createThisExpression() + } + val newExpression = factory.createExpressionByPattern("$0 $1 $2", newLeft, operationReference, right!!) + element.replace(newExpression) + } + } +} + +private fun KtDotQualifiedExpression.applyTo(element: KtCallExpression) { + when (val parent = element.parent) { + is KtQualifiedExpression -> { + val factory = KtPsiFactory(element.project) + val receiver = parent.receiverExpression + parent.replace(replaceFirstReceiver(factory, receiver, parent is KtSafeQualifiedExpression)) + } + else -> { + element.replace(deleteFirstReceiver()) + } + } +} + +private fun KtCallExpression.applyTo(element: KtCallExpression, functionLiteral: KtFunctionLiteral, editor: Editor?) { + val parent = element.parent as? KtQualifiedExpression + val reference = functionLiteral.valueParameterReferences(this).firstOrNull() + val replaced = if (parent != null) { + reference?.replace(parent.receiverExpression) + parent.replaced(this) + } else { + reference?.replace(KtPsiFactory(this).createThisExpression()) + element.replaced(this) + } + editor?.caretModel?.moveToOffset(replaced.startOffset) +} + +private fun KtBinaryExpression.isApplicable(parameterName: String, isTopLevel: Boolean = true): Boolean { + val left = left ?: return false + if (isTopLevel) { + when (left) { + is KtNameReferenceExpression -> if (left.text != parameterName) return false + is KtDotQualifiedExpression -> if (!left.isApplicable(parameterName)) return false + else -> return false + } + } else { + if (!left.isApplicable(parameterName)) return false + } + + val right = right ?: return false + return right.isApplicable(parameterName) +} + +private fun KtExpression.isApplicable(parameterName: String): Boolean = when (this) { + is KtNameReferenceExpression -> text != parameterName + is KtDotQualifiedExpression -> !hasLambdaExpression() && !nameUsed(parameterName) + is KtBinaryExpression -> isApplicable(parameterName, isTopLevel = false) + is KtCallExpression -> isApplicable(parameterName) + is KtConstantExpression -> true + else -> false +} + +private fun KtCallExpression.isApplicable(parameterName: String): Boolean = valueArguments.all { + val argumentExpression = it.getArgumentExpression() ?: return@all false + argumentExpression.isApplicable(parameterName) +} + +private fun KtDotQualifiedExpression.isApplicable(parameterName: String) = + !hasLambdaExpression() && getLeftMostReceiverExpression().let { receiver -> + receiver is KtNameReferenceExpression && + receiver.getReferencedName() == parameterName && + !nameUsed(parameterName, except = receiver) + } && callExpression?.resolveToCall() !is VariableAsFunctionResolvedCall + +private fun KtDotQualifiedExpression.hasLambdaExpression() = selectorExpression?.anyDescendantOfType() ?: false + +private fun KtCallExpression.isLetMethodCall() = calleeExpression?.text == "let" && isMethodCall("kotlin.let") + +private fun KtLambdaExpression.getParameterName(): String? { + val parameters = valueParameters + if (parameters.size > 1) return null + return if (parameters.size == 1) parameters[0].text else "it" +} + +private fun KtExpression.nameUsed(name: String, except: KtNameReferenceExpression? = null): Boolean = + anyDescendantOfType { it != except && it.getReferencedName() == name } + +private fun KtFunctionLiteral.valueParameterReferences(callExpression: KtCallExpression): List { + val context = analyze(BodyResolveMode.PARTIAL) + val parameterDescriptor = context[BindingContext.FUNCTION, this]?.valueParameters?.singleOrNull() ?: return emptyList() + val variableDescriptorByName = if (parameterDescriptor is ValueParameterDescriptorImpl.WithDestructuringDeclaration) + parameterDescriptor.destructuringVariables.associateBy { it.name } + else + mapOf(parameterDescriptor.name to parameterDescriptor) + + val callee = (callExpression.calleeExpression as? KtNameReferenceExpression)?.let { + val descriptor = variableDescriptorByName[it.getReferencedNameAsName()] + if (descriptor != null && it.getReferenceTargets(context).singleOrNull() == descriptor) listOf(it) else null + } ?: emptyList() + return callee + callExpression.valueArguments.flatMap { arg -> + arg.collectDescendantsOfType().filter { + val descriptor = variableDescriptorByName[it.getReferencedNameAsName()] + descriptor != null && it.getResolvedCall(context)?.resultingDescriptor == descriptor + } + } +} + +private fun isSingleLine(element: KtCallExpression): Boolean { + val qualifiedExpression = element.getQualifiedExpressionForSelector() ?: return true + var receiver = qualifiedExpression.receiverExpression as? KtQualifiedExpression ?: return true + if (receiver.lineCount() > 1) return false + var count = 1 + while (true) { + if (count > 2) return false + receiver = receiver.receiverExpression as? KtQualifiedExpression ?: break + count++ + } + return true +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt deleted file mode 100644 index 0edee9dac3b..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceSingleLineLetIntention.kt +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright 2010-2016 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.openapi.editor.Editor -import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl -import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall -import org.jetbrains.kotlin.idea.core.replaced -import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection -import org.jetbrains.kotlin.idea.intentions.branchedTransformations.lineCount -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType -import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType -import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector -import org.jetbrains.kotlin.psi.psiUtil.startOffset -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.bindingContextUtil.getReferenceTargets -import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall -import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode - -class ReplaceSingleLineLetInspection : IntentionBasedInspection( - ReplaceSingleLineLetIntention::class, - { element -> isApplicable(element) } -) { - override fun inspectionTarget(element: KtCallExpression) = element.calleeExpression - - companion object { - fun isApplicable(element: KtCallExpression): Boolean { - val qualifiedExpression = element.getQualifiedExpressionForSelector() ?: return true - var receiver = qualifiedExpression.receiverExpression as? KtQualifiedExpression ?: return true - if (receiver.lineCount() > 1) return false - var count = 1 - while (true) { - if (count > 2) return false - receiver = receiver.receiverExpression as? KtQualifiedExpression ?: break - count++ - } - return true - } - } -} - -class ReplaceSingleLineLetIntention : SelfTargetingOffsetIndependentIntention( - KtCallExpression::class.java, - "Remove redundant '.let' call" -) { - override fun applyTo(element: KtCallExpression, editor: Editor?) { - val lambdaExpression = element.lambdaArguments.firstOrNull()?.getLambdaExpression() ?: return - when (val bodyExpression = lambdaExpression.bodyExpression?.children?.singleOrNull() ?: return) { - is KtDotQualifiedExpression -> bodyExpression.applyTo(element) - is KtBinaryExpression -> bodyExpression.applyTo(element) - is KtCallExpression -> bodyExpression.applyTo(element, lambdaExpression.functionLiteral, editor) - } - } - - private fun KtBinaryExpression.applyTo(element: KtCallExpression) { - val left = left ?: return - val factory = KtPsiFactory(element.project) - when (val parent = element.parent) { - is KtQualifiedExpression -> { - val receiver = parent.receiverExpression - val newLeft = when (left) { - is KtDotQualifiedExpression -> left.replaceFirstReceiver(factory, receiver, parent is KtSafeQualifiedExpression) - else -> receiver - } - val newExpression = factory.createExpressionByPattern("$0 $1 $2", newLeft, operationReference, right!!) - parent.replace(newExpression) - } - else -> { - val newLeft = when (left) { - is KtDotQualifiedExpression -> left.deleteFirstReceiver() - else -> factory.createThisExpression() - } - val newExpression = factory.createExpressionByPattern("$0 $1 $2", newLeft, operationReference, right!!) - element.replace(newExpression) - } - } - } - - private fun KtDotQualifiedExpression.applyTo(element: KtCallExpression) { - when (val parent = element.parent) { - is KtQualifiedExpression -> { - val factory = KtPsiFactory(element.project) - val receiver = parent.receiverExpression - parent.replace(replaceFirstReceiver(factory, receiver, parent is KtSafeQualifiedExpression)) - } - else -> { - element.replace(deleteFirstReceiver()) - } - } - } - - private fun KtCallExpression.applyTo(element: KtCallExpression, functionLiteral: KtFunctionLiteral, editor: Editor?) { - val parent = element.parent as? KtQualifiedExpression - val reference = functionLiteral.valueParameterReferences(this).firstOrNull() - val replaced = if (parent != null) { - reference?.replace(parent.receiverExpression) - parent.replaced(this) - } else { - reference?.replace(KtPsiFactory(this).createThisExpression()) - element.replaced(this) - } - editor?.caretModel?.moveToOffset(replaced.startOffset) - } - - override fun isApplicableTo(element: KtCallExpression): Boolean { - if (!element.isLetMethodCall()) return false - val lambdaExpression = element.lambdaArguments.firstOrNull()?.getLambdaExpression() ?: return false - val parameterName = lambdaExpression.getParameterName() ?: return false - - return when (val bodyExpression = lambdaExpression.bodyExpression?.children?.singleOrNull() ?: return false) { - is KtBinaryExpression -> - element.parent !is KtSafeQualifiedExpression && bodyExpression.isApplicable(parameterName) - is KtDotQualifiedExpression -> - bodyExpression.isApplicable(parameterName) - is KtCallExpression -> - if (element.parent is KtSafeQualifiedExpression) { - false - } else { - val count = lambdaExpression.functionLiteral.valueParameterReferences(bodyExpression).count() - val destructuringDeclaration = lambdaExpression.functionLiteral.valueParameters.firstOrNull()?.destructuringDeclaration - count == 0 || (count == 1 && destructuringDeclaration == null) - } - else -> - false - } - } - - private fun KtBinaryExpression.isApplicable(parameterName: String, isTopLevel: Boolean = true): Boolean { - val left = left ?: return false - if (isTopLevel) { - when (left) { - is KtNameReferenceExpression -> if (left.text != parameterName) return false - is KtDotQualifiedExpression -> if (!left.isApplicable(parameterName)) return false - else -> return false - } - } else { - if (!left.isApplicable(parameterName)) return false - } - - val right = right ?: return false - return right.isApplicable(parameterName) - } - - private fun KtExpression.isApplicable(parameterName: String): Boolean = when (this) { - is KtNameReferenceExpression -> text != parameterName - is KtDotQualifiedExpression -> !hasLambdaExpression() && !nameUsed(parameterName) - is KtBinaryExpression -> isApplicable(parameterName, isTopLevel = false) - is KtCallExpression -> isApplicable(parameterName) - is KtConstantExpression -> true - else -> false - } - - private fun KtCallExpression.isApplicable(parameterName: String): Boolean = valueArguments.all { - val argumentExpression = it.getArgumentExpression() ?: return@all false - argumentExpression.isApplicable(parameterName) - } - - private fun KtDotQualifiedExpression.isApplicable(parameterName: String) = - !hasLambdaExpression() && getLeftMostReceiverExpression().let { receiver -> - receiver is KtNameReferenceExpression && - receiver.getReferencedName() == parameterName && - !nameUsed(parameterName, except = receiver) - } && callExpression?.resolveToCall() !is VariableAsFunctionResolvedCall - - private fun KtDotQualifiedExpression.hasLambdaExpression() = selectorExpression?.anyDescendantOfType() ?: false - - private fun KtCallExpression.isLetMethodCall() = calleeExpression?.text == "let" && isMethodCall("kotlin.let") - - private fun KtLambdaExpression.getParameterName(): String? { - val parameters = valueParameters - if (parameters.size > 1) return null - return if (parameters.size == 1) parameters[0].text else "it" - } - - private fun KtExpression.nameUsed(name: String, except: KtNameReferenceExpression? = null): Boolean = - anyDescendantOfType { it != except && it.getReferencedName() == name } - - private fun KtFunctionLiteral.valueParameterReferences(callExpression: KtCallExpression): List { - val context = analyze(BodyResolveMode.PARTIAL) - val parameterDescriptor = context[BindingContext.FUNCTION, this]?.valueParameters?.singleOrNull() ?: return emptyList() - val variableDescriptorByName = if (parameterDescriptor is ValueParameterDescriptorImpl.WithDestructuringDeclaration) - parameterDescriptor.destructuringVariables.associateBy { it.name } - else - mapOf(parameterDescriptor.name to parameterDescriptor) - - val callee = (callExpression.calleeExpression as? KtNameReferenceExpression)?.let { - val descriptor = variableDescriptorByName[it.getReferencedNameAsName()] - if (descriptor != null && it.getReferenceTargets(context).singleOrNull() == descriptor) listOf(it) else null - } ?: emptyList() - return callee + callExpression.valueArguments.flatMap { arg -> - arg.collectDescendantsOfType().filter { - val descriptor = variableDescriptorByName[it.getReferencedNameAsName()] - descriptor != null && it.getResolvedCall(context)?.resultingDescriptor == descriptor - } - } - } -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt index 3c5df557698..5bbcc358faf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/SafeAccessToIfThenIntention.kt @@ -21,7 +21,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.core.replaced -import org.jetbrains.kotlin.idea.intentions.ReplaceSingleLineLetIntention +import org.jetbrains.kotlin.idea.inspections.ReplaceSingleLineLetInspection import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.convertToIfNotNullExpression import org.jetbrains.kotlin.idea.intentions.branchedTransformations.introduceValueForCondition @@ -87,9 +87,9 @@ class SafeAccessToIfThenIntention : SelfTargetingRangeIntention) { list.filter { it > 1 } diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/callChainWithLineBreak.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/callChainWithLineBreak.kt.after new file mode 100644 index 00000000000..deb1d311d36 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/callChainWithLineBreak.kt.after @@ -0,0 +1,7 @@ +// WITH_RUNTIME +// HIGHLIGHT: INFORMATION + +fun test(list: List) { + println(list.filter { it > 1 } + .filter { it > 2 }) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/comparisons.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/comparisons.kt similarity index 80% rename from idea/testData/intentions/replaceSingleLineLetIntention/comparisons.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/comparisons.kt index 85b18e7f551..965d929d6bd 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/comparisons.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/comparisons.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // WITH_RUNTIME fun isAlphaOrBeta(str: String) = str.let { it == "Alpha" || it == "Beta" } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration2.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration2.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration2.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration2.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration2.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration2.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration2.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration2.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration3.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration3.kt similarity index 82% rename from idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration3.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration3.kt index 87530bfa984..da297683870 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration3.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration3.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun test() { (1 to 2).let { (i, j) -> foo(i, 3) } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration4.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration4.kt similarity index 77% rename from idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration4.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration4.kt index 6e37d9866f4..41a00afaab8 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration4.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration4.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun test(k: Int) { (1 to 2).let { (i, j) -> i + k } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration5.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration5.kt similarity index 76% rename from idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration5.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration5.kt index 66ae96754f0..bb26cfe0ca9 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration5.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration5.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun test() { (1 to 2).let { (i, j) -> i.toLong() } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/dotWithComparison.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/dotWithComparison.kt similarity index 83% rename from idea/testData/intentions/replaceSingleLineLetIntention/dotWithComparison.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/dotWithComparison.kt index 99457243ed6..24c6ed0c802 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/dotWithComparison.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/dotWithComparison.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // WITH_RUNTIME fun main(args: Array) { diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall1.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall1.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall1.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall1.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall1.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall1.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall1.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall1.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall2.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall2.kt similarity index 73% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall2.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall2.kt index 4accb193e75..34d7eb3a4f9 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall2.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall2.kt @@ -4,5 +4,5 @@ fun foo(s: String, i: Int) = s.length + i fun test() { val s = "" - s.let { foo(it, 1) } + s.let { foo(it, 1) } } \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall2.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall2.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall2.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall2.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall3.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall3.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall3.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall3.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall3.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall3.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall3.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall3.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall4.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall4.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall4.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall4.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall4.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall4.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall4.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall4.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall5.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall5.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall5.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall5.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall5.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall5.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall5.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall5.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall6.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall6.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall6.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall6.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall6.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall6.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall6.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall6.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall7.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall7.kt similarity index 84% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCall7.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall7.kt index 7918b5a8fb2..e289957ee5f 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/functionCall7.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall7.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo(s: String, i: Int) = s.length + i diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCallInExtension.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallInExtension.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCallInExtension.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallInExtension.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCallInExtension.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallInExtension.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCallInExtension.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallInExtension.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionCallOnSafeCall.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallOnSafeCall.kt similarity index 85% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionCallOnSafeCall.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallOnSafeCall.kt index 9f129500089..467aa7baf44 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/functionCallOnSafeCall.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallOnSafeCall.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo(s: String, i: Int) = s.length + i diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionInVariableCall.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableCall.kt similarity index 80% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionInVariableCall.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableCall.kt index 4a50e17b69f..1340729dbca 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/functionInVariableCall.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableCall.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // WITH_RUNTIME class Foo(val bar: () -> Int) diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionInVariableInvokeCall.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableInvokeCall.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionInVariableInvokeCall.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableInvokeCall.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/functionInVariableInvokeCall.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableInvokeCall.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/functionInVariableInvokeCall.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableInvokeCall.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/in.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt similarity index 81% rename from idea/testData/intentions/replaceSingleLineLetIntention/in.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt index 2ee7210e378..dcdf9515898 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/in.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo(list: List) { list.filter { it.let { it in 1000..3000 } } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/in.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt.after similarity index 78% rename from idea/testData/intentions/replaceSingleLineLetIntention/in.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt.after index 5ca4a89cc73..a8b3df875d3 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/in.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo(list: List) { list.filter { it in 1000..3000 } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/inWithMultipleParam.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithMultipleParam.kt similarity index 82% rename from idea/testData/intentions/replaceSingleLineLetIntention/inWithMultipleParam.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/inWithMultipleParam.kt index dc73ad41f37..9e257d0885f 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/inWithMultipleParam.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithMultipleParam.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo(list: List) { list.filter { it.let { value -> value in value..3000 } } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/inWithRange.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt similarity index 82% rename from idea/testData/intentions/replaceSingleLineLetIntention/inWithRange.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt index 7d01eb46ea4..8f717491e03 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/inWithRange.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo(list: List) { list.filter { it.let { it in IntRange(1, 10) } } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/inWithRange.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt.after similarity index 79% rename from idea/testData/intentions/replaceSingleLineLetIntention/inWithRange.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt.after index 515a38d852b..c582e2644a0 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/inWithRange.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo(list: List) { list.filter { it in IntRange(1, 10) } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/inWithRangeMultipleParam.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRangeMultipleParam.kt similarity index 82% rename from idea/testData/intentions/replaceSingleLineLetIntention/inWithRangeMultipleParam.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRangeMultipleParam.kt index 7aafc23970a..6b7ed9d85c3 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/inWithRangeMultipleParam.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRangeMultipleParam.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo(list: List) { list.filter { it.let { it in IntRange(it - 1, 10) } } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/invokeCall.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/invokeCall.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/invokeCall.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/invokeCall.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/invokeCall2.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall2.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/invokeCall2.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall2.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/invokeCall2.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall2.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/invokeCall2.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall2.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/invokeCall3.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall3.kt similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/invokeCall3.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall3.kt diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/invokeCall3.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall3.kt.after similarity index 100% rename from idea/testData/intentions/replaceSingleLineLetIntention/invokeCall3.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall3.kt.after diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/invokeCall4.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall4.kt similarity index 83% rename from idea/testData/intentions/replaceSingleLineLetIntention/invokeCall4.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall4.kt index e99b38d9f6c..c65abc1d33d 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/invokeCall4.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall4.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // WITH_RUNTIME class A { operator fun invoke(a: A, i: Int) {} diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/invokeCall5.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall5.kt similarity index 82% rename from idea/testData/intentions/replaceSingleLineLetIntention/invokeCall5.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall5.kt index a3743aa7468..c1f848c977f 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/invokeCall5.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall5.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // WITH_RUNTIME class A { operator fun invoke() {} diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression.kt similarity index 81% rename from idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression.kt index 23db56267bc..c969dbfab90 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun baz(foo: String) { foo.let { it.indexOfLast { c -> c == it[0] } + 1 } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression2.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression2.kt similarity index 82% rename from idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression2.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression2.kt index 67e99fb1e30..884a6f3c82b 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression2.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression2.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun baz(foo: String) { foo.let { it.length + "".indexOfLast { c -> c == it[0] } } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/let.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt similarity index 50% rename from idea/testData/intentions/replaceSingleLineLetIntention/let.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt index 0b9b90037f2..c01b6b859ed 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/let.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt @@ -1,9 +1,9 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { val foo: String? = null - foo?.let { - it.length + foo?.let { + it.length } } \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/let.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt.after similarity index 76% rename from idea/testData/intentions/replaceSingleLineLetIntention/let.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt.after index 08f96ff2517..92c8e02a3fc 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/let.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letMultipleLines.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letMultipleLines.kt similarity index 83% rename from idea/testData/intentions/replaceSingleLineLetIntention/letMultipleLines.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letMultipleLines.kt index 5f375de264d..5032dc961a9 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letMultipleLines.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letMultipleLines.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { val foo: String? = null diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt new file mode 100644 index 00000000000..31d8b022501 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME + + +fun foo() { + val foo: String = "" + foo.let { + it.length + } +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letNoSafeCall.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt.after similarity index 75% rename from idea/testData/intentions/replaceSingleLineLetIntention/letNoSafeCall.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt.after index 63ca0d692d5..445210de73d 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letNoSafeCall.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { val foo: String = "" diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letNotUseParameterReceiver.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseParameterReceiver.kt similarity index 83% rename from idea/testData/intentions/replaceSingleLineLetIntention/letNotUseParameterReceiver.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseParameterReceiver.kt index 5a36bd1d600..e12a770cc93 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letNotUseParameterReceiver.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseParameterReceiver.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letNotUseReceiver.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseReceiver.kt similarity index 81% rename from idea/testData/intentions/replaceSingleLineLetIntention/letNotUseReceiver.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseReceiver.kt index c0d9c357bb3..f4fcf8a9919 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letNotUseReceiver.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseReceiver.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letUseIt.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseIt.kt similarity index 81% rename from idea/testData/intentions/replaceSingleLineLetIntention/letUseIt.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letUseIt.kt index 4efefd69b99..a2423ec4d4a 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letUseIt.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseIt.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItAsParamWithBinaryExpression.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItAsParamWithBinaryExpression.kt similarity index 76% rename from idea/testData/intentions/replaceSingleLineLetIntention/letUseItAsParamWithBinaryExpression.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItAsParamWithBinaryExpression.kt index 61609c11507..b8bf79bb237 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItAsParamWithBinaryExpression.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItAsParamWithBinaryExpression.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { "".let { it.length + "".indexOf(it) } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithBinaryExpression.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression.kt similarity index 75% rename from idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithBinaryExpression.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression.kt index 5b207566566..f49ef207cae 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithBinaryExpression.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { "".let { it.length + it.length } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithBinaryExpression2.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression2.kt similarity index 76% rename from idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithBinaryExpression2.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression2.kt index 25d349fdf99..5fd8404ab80 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithBinaryExpression2.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression2.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { "".let { it.substring(0, 1) + it } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall1.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall1.kt similarity index 83% rename from idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall1.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall1.kt index 9e5117ecc9f..05fddfe9c0d 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall1.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall1.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall2.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall2.kt similarity index 83% rename from idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall2.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall2.kt index b1f95237ce3..12064396a0c 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall2.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall2.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall3.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall3.kt similarity index 83% rename from idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall3.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall3.kt index 80d7191b9c1..bd963a6660e 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall3.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall3.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letUseParameter.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseParameter.kt similarity index 83% rename from idea/testData/intentions/replaceSingleLineLetIntention/letUseParameter.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letUseParameter.kt index 9881425472c..cb69fc48841 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letUseParameter.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letUseParameter.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithBinaryExpression.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt similarity index 74% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithBinaryExpression.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt index 9a57302c24b..a0d6d2b0a0a 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithBinaryExpression.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { "".let { it.length + 1 } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithBinaryExpression.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt.after similarity index 67% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithBinaryExpression.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt.after index 8bcd30515f3..c6192780957 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithBinaryExpression.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { "".length + 1 diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithMethodCall.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt similarity index 50% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithMethodCall.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt index 540745b84d4..70ea6a79224 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithMethodCall.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt @@ -1,9 +1,9 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { val foo: String? = null - foo?.let { - it.to("") + foo?.let { + it.to("") } } \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithMethodCall.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt.after similarity index 76% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithMethodCall.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt.after index c836459393b..8e7b979df01 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithMethodCall.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { val foo: String? = null diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt new file mode 100644 index 00000000000..e785da74f2d --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME + + +fun foo() { + val foo: String? = null + foo?.let { + it.hashCode().hashCode() + } +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithMultipleMethodCall.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt.after similarity index 79% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithMultipleMethodCall.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt.after index 2ad7d4ba2bc..1e5eb33548c 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithMultipleMethodCall.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithParameter.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt similarity index 55% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithParameter.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt index b7dcf0a44dd..58fd609491a 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithParameter.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt @@ -1,10 +1,10 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { val foo: String? = null - foo?.let { + foo?.let { text -> - text.length + text.length } } \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithParameter.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt.after similarity index 76% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithParameter.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt.after index 08f96ff2517..92c8e02a3fc 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithParameter.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithSimpleBinaryExpression.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt similarity index 71% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithSimpleBinaryExpression.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt index 61e653185a0..23150952064 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithSimpleBinaryExpression.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { "".let { it + 1 } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithSimpleBinaryExpression.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt.after similarity index 64% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithSimpleBinaryExpression.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt.after index 3ae32ba8c97..61fe574e505 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithSimpleBinaryExpression.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { "" + 1 diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithThisBinaryExpression.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt similarity index 74% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithThisBinaryExpression.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt index 2c3fc8bccb0..748d3902efc 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithThisBinaryExpression.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun Int.foo() { let { it.dec() + 1 } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithThisBinaryExpression.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt.after similarity index 67% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithThisBinaryExpression.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt.after index 413570fd47d..72bef781423 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithThisBinaryExpression.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun Int.foo() { dec() + 1 diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithThisShortBinaryExpression.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt similarity index 72% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithThisShortBinaryExpression.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt index f05639c5168..2af45f703ec 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithThisShortBinaryExpression.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun Int.foo() { let { it + 1 } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithThisShortBinaryExpression.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt.after similarity index 67% rename from idea/testData/intentions/replaceSingleLineLetIntention/letWithThisShortBinaryExpression.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt.after index 21e066415dd..2a37592d960 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithThisShortBinaryExpression.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun Int.foo() { this + 1 diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt index f1087232e22..bc887f97fcf 100644 --- a/idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// PROBLEM: none +// HIGHLIGHT: INFORMATION fun test(list: List) { list.filter { it > 1 }.filter { it > 2 }.filter { it > 3 }.let { println(it) } diff --git a/idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt.after new file mode 100644 index 00000000000..59f1f31ffd0 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt.after @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// HIGHLIGHT: INFORMATION + +fun test(list: List) { + println(list.filter { it > 1 }.filter { it > 2 }.filter { it > 3 }) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver.kt similarity index 81% rename from idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver.kt index 0dcf2055ab7..afa1d6a16a6 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun baz(foo: String) { foo.let { it.substringAfterLast(it.capitalize()) } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver2.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver2.kt similarity index 82% rename from idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver2.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver2.kt index 7ad515f49e7..ce7973f7ff5 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver2.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver2.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun baz(foo: String) { foo.let { it.substringAfterLast("".equals(it).toString()) } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver3.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver3.kt similarity index 79% rename from idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver3.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver3.kt index 0d87447d99e..b7370b83e6a 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver3.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver3.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun baz(foo: String) { foo.let { it.substring(0, it.length) } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/multipleUsages.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleUsages.kt similarity index 84% rename from idea/testData/intentions/replaceSingleLineLetIntention/multipleUsages.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/multipleUsages.kt index c6c5b260b57..a624c9d591f 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/multipleUsages.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/multipleUsages.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // WITH_RUNTIME fun foo(s: String) { diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/plusNullable.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/plusNullable.kt similarity index 77% rename from idea/testData/intentions/replaceSingleLineLetIntention/plusNullable.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/plusNullable.kt index f24ae2bf4af..e194ff9b290 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/plusNullable.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/plusNullable.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // WITH_RUNTIME fun plusNullable(arg: String?) = arg?.let { it + "#" } ?: "" \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/receiverWithLambda.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda.kt similarity index 80% rename from idea/testData/intentions/replaceSingleLineLetIntention/receiverWithLambda.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda.kt index d483a3f7c3e..750f2aeb2bf 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/receiverWithLambda.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none fun baz(foo: String) { foo.let { it.indexOfLast { c -> c == it[0] } } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/receiverWithLambda2.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda2.kt similarity index 91% rename from idea/testData/intentions/replaceSingleLineLetIntention/receiverWithLambda2.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda2.kt index a081fea06e5..d14367fde03 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/receiverWithLambda2.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda2.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: false +// PROBLEM: none // This should be reported. However, in order to avoid too complicate logic, the intention ignore this case. import java.util.* diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/sameLets.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt similarity index 55% rename from idea/testData/intentions/replaceSingleLineLetIntention/sameLets.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt index 1e71048d0e4..78aa61af860 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/sameLets.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt @@ -1,10 +1,10 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { val foo: String? = null - foo?.toString()?.let { - it.to("") + foo?.toString()?.let { + it.to("") }?.let { it.to("") } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/sameLets.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt.after similarity index 83% rename from idea/testData/intentions/replaceSingleLineLetIntention/sameLets.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt.after index 05cd5886c4c..b83dd24b8cc 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/sameLets.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun foo() { val foo: String? = null diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/smartCastInBody.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/smartCastInBody.kt similarity index 89% rename from idea/testData/intentions/replaceSingleLineLetIntention/smartCastInBody.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/smartCastInBody.kt index 81862c70028..9262320b54f 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/smartCastInBody.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/smartCastInBody.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // WITH_RUNTIME interface A diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/this.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt similarity index 79% rename from idea/testData/intentions/replaceSingleLineLetIntention/this.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt index c34c1a65872..5bd1f92f629 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/this.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun Int.foo(): Int { return let { it.hashCode().hashCode() } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/this.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt.after similarity index 75% rename from idea/testData/intentions/replaceSingleLineLetIntention/this.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt.after index bd7b5c17b54..176642f1d94 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/this.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun Int.foo(): Int { return hashCode().hashCode() diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/thisShort.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt similarity index 77% rename from idea/testData/intentions/replaceSingleLineLetIntention/thisShort.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt index 6c0e26bcb33..77078d9fd2e 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/thisShort.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun Int.foo(): Int { return let { it.hashCode() } diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/thisShort.kt.after b/idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt.after similarity index 72% rename from idea/testData/intentions/replaceSingleLineLetIntention/thisShort.kt.after rename to idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt.after index 399c9c1a372..4b6be023661 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/thisShort.kt.after +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt.after @@ -1,5 +1,5 @@ // WITH_RUNTIME -// IS_APPLICABLE: true + fun Int.foo(): Int { return hashCode() diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/typeChecks.kt b/idea/testData/inspectionsLocal/replaceSingleLineLet/typeChecks.kt similarity index 83% rename from idea/testData/intentions/replaceSingleLineLetIntention/typeChecks.kt rename to idea/testData/inspectionsLocal/replaceSingleLineLet/typeChecks.kt index 5f629178f55..064f36d2ec3 100644 --- a/idea/testData/intentions/replaceSingleLineLetIntention/typeChecks.kt +++ b/idea/testData/inspectionsLocal/replaceSingleLineLet/typeChecks.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // WITH_RUNTIME interface Base diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/.intention b/idea/testData/intentions/replaceSingleLineLetIntention/.intention deleted file mode 100644 index dff5fcac91f..00000000000 --- a/idea/testData/intentions/replaceSingleLineLetIntention/.intention +++ /dev/null @@ -1 +0,0 @@ -org.jetbrains.kotlin.idea.intentions.ReplaceSingleLineLetIntention \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letNoSafeCall.kt b/idea/testData/intentions/replaceSingleLineLetIntention/letNoSafeCall.kt deleted file mode 100644 index 8eabad15e70..00000000000 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letNoSafeCall.kt +++ /dev/null @@ -1,9 +0,0 @@ -// WITH_RUNTIME -// IS_APPLICABLE: true - -fun foo() { - val foo: String = "" - foo.let { - it.length - } -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceSingleLineLetIntention/letWithMultipleMethodCall.kt b/idea/testData/intentions/replaceSingleLineLetIntention/letWithMultipleMethodCall.kt deleted file mode 100644 index 07ace3e0b5d..00000000000 --- a/idea/testData/intentions/replaceSingleLineLetIntention/letWithMultipleMethodCall.kt +++ /dev/null @@ -1,9 +0,0 @@ -// WITH_RUNTIME -// IS_APPLICABLE: true - -fun foo() { - val foo: String? = null - foo?.let { - it.hashCode().hashCode() - } -} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index 29a20476026..2d9d29c87d6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -9310,6 +9310,16 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/replaceSingleLineLet"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); } + @TestMetadata("assignment.kt") + public void testAssignment() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/assignment.kt"); + } + + @TestMetadata("binarySafeCall.kt") + public void testBinarySafeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/binarySafeCall.kt"); + } + @TestMetadata("callChain.kt") public void testCallChain() throws Exception { runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/callChain.kt"); @@ -9330,20 +9340,325 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/callChainWithLineBreak.kt"); } + @TestMetadata("comparisons.kt") + public void testComparisons() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/comparisons.kt"); + } + + @TestMetadata("destructuringDeclaration.kt") + public void testDestructuringDeclaration() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration.kt"); + } + + @TestMetadata("destructuringDeclaration2.kt") + public void testDestructuringDeclaration2() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration2.kt"); + } + + @TestMetadata("destructuringDeclaration3.kt") + public void testDestructuringDeclaration3() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration3.kt"); + } + + @TestMetadata("destructuringDeclaration4.kt") + public void testDestructuringDeclaration4() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration4.kt"); + } + + @TestMetadata("destructuringDeclaration5.kt") + public void testDestructuringDeclaration5() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/destructuringDeclaration5.kt"); + } + + @TestMetadata("dotWithComparison.kt") + public void testDotWithComparison() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/dotWithComparison.kt"); + } + + @TestMetadata("functionCall1.kt") + public void testFunctionCall1() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall1.kt"); + } + + @TestMetadata("functionCall2.kt") + public void testFunctionCall2() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall2.kt"); + } + + @TestMetadata("functionCall3.kt") + public void testFunctionCall3() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall3.kt"); + } + + @TestMetadata("functionCall4.kt") + public void testFunctionCall4() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall4.kt"); + } + + @TestMetadata("functionCall5.kt") + public void testFunctionCall5() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall5.kt"); + } + + @TestMetadata("functionCall6.kt") + public void testFunctionCall6() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall6.kt"); + } + + @TestMetadata("functionCall7.kt") + public void testFunctionCall7() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCall7.kt"); + } + + @TestMetadata("functionCallInExtension.kt") + public void testFunctionCallInExtension() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallInExtension.kt"); + } + + @TestMetadata("functionCallOnSafeCall.kt") + public void testFunctionCallOnSafeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionCallOnSafeCall.kt"); + } + + @TestMetadata("functionInVariableCall.kt") + public void testFunctionInVariableCall() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableCall.kt"); + } + + @TestMetadata("functionInVariableInvokeCall.kt") + public void testFunctionInVariableInvokeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/functionInVariableInvokeCall.kt"); + } + + @TestMetadata("in.kt") + public void testIn() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/in.kt"); + } + + @TestMetadata("inWithMultipleParam.kt") + public void testInWithMultipleParam() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/inWithMultipleParam.kt"); + } + + @TestMetadata("inWithRange.kt") + public void testInWithRange() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRange.kt"); + } + + @TestMetadata("inWithRangeMultipleParam.kt") + public void testInWithRangeMultipleParam() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/inWithRangeMultipleParam.kt"); + } + + @TestMetadata("invokeCall.kt") + public void testInvokeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall.kt"); + } + + @TestMetadata("invokeCall2.kt") + public void testInvokeCall2() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall2.kt"); + } + + @TestMetadata("invokeCall3.kt") + public void testInvokeCall3() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall3.kt"); + } + + @TestMetadata("invokeCall4.kt") + public void testInvokeCall4() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall4.kt"); + } + + @TestMetadata("invokeCall5.kt") + public void testInvokeCall5() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/invokeCall5.kt"); + } + + @TestMetadata("lambdaWithBinaryExpression.kt") + public void testLambdaWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression.kt"); + } + + @TestMetadata("lambdaWithBinaryExpression2.kt") + public void testLambdaWithBinaryExpression2() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/lambdaWithBinaryExpression2.kt"); + } + + @TestMetadata("let.kt") + public void testLet() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/let.kt"); + } + + @TestMetadata("letMultipleLines.kt") + public void testLetMultipleLines() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letMultipleLines.kt"); + } + + @TestMetadata("letNoSafeCall.kt") + public void testLetNoSafeCall() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letNoSafeCall.kt"); + } + + @TestMetadata("letNotUseParameterReceiver.kt") + public void testLetNotUseParameterReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseParameterReceiver.kt"); + } + + @TestMetadata("letNotUseReceiver.kt") + public void testLetNotUseReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letNotUseReceiver.kt"); + } + + @TestMetadata("letUseIt.kt") + public void testLetUseIt() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseIt.kt"); + } + + @TestMetadata("letUseItAsParamWithBinaryExpression.kt") + public void testLetUseItAsParamWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItAsParamWithBinaryExpression.kt"); + } + + @TestMetadata("letUseItWithBinaryExpression.kt") + public void testLetUseItWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression.kt"); + } + + @TestMetadata("letUseItWithBinaryExpression2.kt") + public void testLetUseItWithBinaryExpression2() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithBinaryExpression2.kt"); + } + + @TestMetadata("letUseItWithMultipleMethodCall1.kt") + public void testLetUseItWithMultipleMethodCall1() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall1.kt"); + } + + @TestMetadata("letUseItWithMultipleMethodCall2.kt") + public void testLetUseItWithMultipleMethodCall2() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall2.kt"); + } + + @TestMetadata("letUseItWithMultipleMethodCall3.kt") + public void testLetUseItWithMultipleMethodCall3() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseItWithMultipleMethodCall3.kt"); + } + + @TestMetadata("letUseParameter.kt") + public void testLetUseParameter() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letUseParameter.kt"); + } + + @TestMetadata("letWithBinaryExpression.kt") + public void testLetWithBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithBinaryExpression.kt"); + } + + @TestMetadata("letWithMethodCall.kt") + public void testLetWithMethodCall() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMethodCall.kt"); + } + + @TestMetadata("letWithMultipleMethodCall.kt") + public void testLetWithMultipleMethodCall() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithMultipleMethodCall.kt"); + } + + @TestMetadata("letWithParameter.kt") + public void testLetWithParameter() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithParameter.kt"); + } + + @TestMetadata("letWithSimpleBinaryExpression.kt") + public void testLetWithSimpleBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithSimpleBinaryExpression.kt"); + } + + @TestMetadata("letWithThisBinaryExpression.kt") + public void testLetWithThisBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisBinaryExpression.kt"); + } + + @TestMetadata("letWithThisShortBinaryExpression.kt") + public void testLetWithThisShortBinaryExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/letWithThisShortBinaryExpression.kt"); + } + @TestMetadata("longCallChain.kt") public void testLongCallChain() throws Exception { runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/longCallChain.kt"); } + @TestMetadata("multipleReceiver.kt") + public void testMultipleReceiver() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver.kt"); + } + + @TestMetadata("multipleReceiver2.kt") + public void testMultipleReceiver2() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver2.kt"); + } + + @TestMetadata("multipleReceiver3.kt") + public void testMultipleReceiver3() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/multipleReceiver3.kt"); + } + + @TestMetadata("multipleUsages.kt") + public void testMultipleUsages() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/multipleUsages.kt"); + } + @TestMetadata("noReceiver.kt") public void testNoReceiver() throws Exception { runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/noReceiver.kt"); } + @TestMetadata("plusNullable.kt") + public void testPlusNullable() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/plusNullable.kt"); + } + + @TestMetadata("receiverWithLambda.kt") + public void testReceiverWithLambda() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda.kt"); + } + + @TestMetadata("receiverWithLambda2.kt") + public void testReceiverWithLambda2() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/receiverWithLambda2.kt"); + } + + @TestMetadata("sameLets.kt") + public void testSameLets() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/sameLets.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/simple.kt"); } + + @TestMetadata("smartCastInBody.kt") + public void testSmartCastInBody() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/smartCastInBody.kt"); + } + + @TestMetadata("this.kt") + public void testThis() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/this.kt"); + } + + @TestMetadata("thisShort.kt") + public void testThisShort() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/thisShort.kt"); + } + + @TestMetadata("typeChecks.kt") + public void testTypeChecks() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceSingleLineLet/typeChecks.kt"); + } } @TestMetadata("idea/testData/inspectionsLocal/replaceStringFormatWithLiteral") diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 3f8ece8cba5..2605ceea28f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -14137,334 +14137,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { } } - @TestMetadata("idea/testData/intentions/replaceSingleLineLetIntention") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ReplaceSingleLineLetIntention extends AbstractIntentionTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); - } - - public void testAllFilesPresentInReplaceSingleLineLetIntention() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/replaceSingleLineLetIntention"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); - } - - @TestMetadata("assignment.kt") - public void testAssignment() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/assignment.kt"); - } - - @TestMetadata("binarySafeCall.kt") - public void testBinarySafeCall() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/binarySafeCall.kt"); - } - - @TestMetadata("comparisons.kt") - public void testComparisons() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/comparisons.kt"); - } - - @TestMetadata("destructuringDeclaration.kt") - public void testDestructuringDeclaration() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration.kt"); - } - - @TestMetadata("destructuringDeclaration2.kt") - public void testDestructuringDeclaration2() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration2.kt"); - } - - @TestMetadata("destructuringDeclaration3.kt") - public void testDestructuringDeclaration3() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration3.kt"); - } - - @TestMetadata("destructuringDeclaration4.kt") - public void testDestructuringDeclaration4() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration4.kt"); - } - - @TestMetadata("destructuringDeclaration5.kt") - public void testDestructuringDeclaration5() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/destructuringDeclaration5.kt"); - } - - @TestMetadata("dotWithComparison.kt") - public void testDotWithComparison() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/dotWithComparison.kt"); - } - - @TestMetadata("functionCall1.kt") - public void testFunctionCall1() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionCall1.kt"); - } - - @TestMetadata("functionCall2.kt") - public void testFunctionCall2() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionCall2.kt"); - } - - @TestMetadata("functionCall3.kt") - public void testFunctionCall3() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionCall3.kt"); - } - - @TestMetadata("functionCall4.kt") - public void testFunctionCall4() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionCall4.kt"); - } - - @TestMetadata("functionCall5.kt") - public void testFunctionCall5() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionCall5.kt"); - } - - @TestMetadata("functionCall6.kt") - public void testFunctionCall6() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionCall6.kt"); - } - - @TestMetadata("functionCall7.kt") - public void testFunctionCall7() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionCall7.kt"); - } - - @TestMetadata("functionCallInExtension.kt") - public void testFunctionCallInExtension() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionCallInExtension.kt"); - } - - @TestMetadata("functionCallOnSafeCall.kt") - public void testFunctionCallOnSafeCall() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionCallOnSafeCall.kt"); - } - - @TestMetadata("functionInVariableCall.kt") - public void testFunctionInVariableCall() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionInVariableCall.kt"); - } - - @TestMetadata("functionInVariableInvokeCall.kt") - public void testFunctionInVariableInvokeCall() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/functionInVariableInvokeCall.kt"); - } - - @TestMetadata("in.kt") - public void testIn() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/in.kt"); - } - - @TestMetadata("inWithMultipleParam.kt") - public void testInWithMultipleParam() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/inWithMultipleParam.kt"); - } - - @TestMetadata("inWithRange.kt") - public void testInWithRange() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/inWithRange.kt"); - } - - @TestMetadata("inWithRangeMultipleParam.kt") - public void testInWithRangeMultipleParam() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/inWithRangeMultipleParam.kt"); - } - - @TestMetadata("invokeCall.kt") - public void testInvokeCall() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/invokeCall.kt"); - } - - @TestMetadata("invokeCall2.kt") - public void testInvokeCall2() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/invokeCall2.kt"); - } - - @TestMetadata("invokeCall3.kt") - public void testInvokeCall3() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/invokeCall3.kt"); - } - - @TestMetadata("invokeCall4.kt") - public void testInvokeCall4() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/invokeCall4.kt"); - } - - @TestMetadata("invokeCall5.kt") - public void testInvokeCall5() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/invokeCall5.kt"); - } - - @TestMetadata("lambdaWithBinaryExpression.kt") - public void testLambdaWithBinaryExpression() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression.kt"); - } - - @TestMetadata("lambdaWithBinaryExpression2.kt") - public void testLambdaWithBinaryExpression2() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/lambdaWithBinaryExpression2.kt"); - } - - @TestMetadata("let.kt") - public void testLet() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/let.kt"); - } - - @TestMetadata("letMultipleLines.kt") - public void testLetMultipleLines() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letMultipleLines.kt"); - } - - @TestMetadata("letNoSafeCall.kt") - public void testLetNoSafeCall() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letNoSafeCall.kt"); - } - - @TestMetadata("letNotUseParameterReceiver.kt") - public void testLetNotUseParameterReceiver() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letNotUseParameterReceiver.kt"); - } - - @TestMetadata("letNotUseReceiver.kt") - public void testLetNotUseReceiver() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letNotUseReceiver.kt"); - } - - @TestMetadata("letUseIt.kt") - public void testLetUseIt() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letUseIt.kt"); - } - - @TestMetadata("letUseItAsParamWithBinaryExpression.kt") - public void testLetUseItAsParamWithBinaryExpression() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letUseItAsParamWithBinaryExpression.kt"); - } - - @TestMetadata("letUseItWithBinaryExpression.kt") - public void testLetUseItWithBinaryExpression() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithBinaryExpression.kt"); - } - - @TestMetadata("letUseItWithBinaryExpression2.kt") - public void testLetUseItWithBinaryExpression2() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithBinaryExpression2.kt"); - } - - @TestMetadata("letUseItWithMultipleMethodCall1.kt") - public void testLetUseItWithMultipleMethodCall1() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall1.kt"); - } - - @TestMetadata("letUseItWithMultipleMethodCall2.kt") - public void testLetUseItWithMultipleMethodCall2() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall2.kt"); - } - - @TestMetadata("letUseItWithMultipleMethodCall3.kt") - public void testLetUseItWithMultipleMethodCall3() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letUseItWithMultipleMethodCall3.kt"); - } - - @TestMetadata("letUseParameter.kt") - public void testLetUseParameter() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letUseParameter.kt"); - } - - @TestMetadata("letWithBinaryExpression.kt") - public void testLetWithBinaryExpression() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letWithBinaryExpression.kt"); - } - - @TestMetadata("letWithMethodCall.kt") - public void testLetWithMethodCall() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letWithMethodCall.kt"); - } - - @TestMetadata("letWithMultipleMethodCall.kt") - public void testLetWithMultipleMethodCall() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letWithMultipleMethodCall.kt"); - } - - @TestMetadata("letWithParameter.kt") - public void testLetWithParameter() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letWithParameter.kt"); - } - - @TestMetadata("letWithSimpleBinaryExpression.kt") - public void testLetWithSimpleBinaryExpression() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letWithSimpleBinaryExpression.kt"); - } - - @TestMetadata("letWithThisBinaryExpression.kt") - public void testLetWithThisBinaryExpression() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letWithThisBinaryExpression.kt"); - } - - @TestMetadata("letWithThisShortBinaryExpression.kt") - public void testLetWithThisShortBinaryExpression() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/letWithThisShortBinaryExpression.kt"); - } - - @TestMetadata("multipleReceiver.kt") - public void testMultipleReceiver() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver.kt"); - } - - @TestMetadata("multipleReceiver2.kt") - public void testMultipleReceiver2() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver2.kt"); - } - - @TestMetadata("multipleReceiver3.kt") - public void testMultipleReceiver3() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/multipleReceiver3.kt"); - } - - @TestMetadata("multipleUsages.kt") - public void testMultipleUsages() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/multipleUsages.kt"); - } - - @TestMetadata("plusNullable.kt") - public void testPlusNullable() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/plusNullable.kt"); - } - - @TestMetadata("receiverWithLambda.kt") - public void testReceiverWithLambda() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/receiverWithLambda.kt"); - } - - @TestMetadata("receiverWithLambda2.kt") - public void testReceiverWithLambda2() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/receiverWithLambda2.kt"); - } - - @TestMetadata("sameLets.kt") - public void testSameLets() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/sameLets.kt"); - } - - @TestMetadata("smartCastInBody.kt") - public void testSmartCastInBody() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/smartCastInBody.kt"); - } - - @TestMetadata("this.kt") - public void testThis() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/this.kt"); - } - - @TestMetadata("thisShort.kt") - public void testThisShort() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/thisShort.kt"); - } - - @TestMetadata("typeChecks.kt") - public void testTypeChecks() throws Exception { - runTest("idea/testData/intentions/replaceSingleLineLetIntention/typeChecks.kt"); - } - } - @TestMetadata("idea/testData/intentions/replaceSizeCheckWithIsNotEmpty") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)