From dc0cbaaf38d19591024ffeda2fa4fc4a314f2e27 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Sat, 6 Jul 2024 21:38:50 +0200 Subject: [PATCH] [kotlin] Align k2 test data with k1 #KTIJ-22991 Fixed GitOrigin-RevId: 119306382462b3613d4fa773ccccfa33b8f44936 --- .../introduceVariable/afterExpression.kt.after.k2 | 6 ------ .../introduceVariable/atExpressionEnd.kt.after.k2 | 6 ------ .../introduceVariable/atExpressionStart.kt.after.k2 | 6 ------ .../introduceVariable/atNestedExpression.kt.after.k2 | 6 ------ .../introduceVariable/K2IntroduceVariableHandler.kt | 2 +- 5 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 plugins/kotlin/idea/tests/testData/intentions/introduceVariable/afterExpression.kt.after.k2 delete mode 100644 plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atExpressionEnd.kt.after.k2 delete mode 100644 plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atExpressionStart.kt.after.k2 delete mode 100644 plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atNestedExpression.kt.after.k2 diff --git a/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/afterExpression.kt.after.k2 b/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/afterExpression.kt.after.k2 deleted file mode 100644 index 1a7fe2032655..000000000000 --- a/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/afterExpression.kt.after.k2 +++ /dev/null @@ -1,6 +0,0 @@ -fun foo(a: Int, b: Int) = a + b - -fun foo() { - val foo = foo(1 + 2, 3 * 4) // -// AFTER-WARNING: Variable 'foo' is never used -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atExpressionEnd.kt.after.k2 b/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atExpressionEnd.kt.after.k2 deleted file mode 100644 index 4c9ffa388d2b..000000000000 --- a/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atExpressionEnd.kt.after.k2 +++ /dev/null @@ -1,6 +0,0 @@ -// AFTER-WARNING: Variable 'foo' is never used -fun foo(a: Int, b: Int) = a + b - -fun foo() { - val foo = foo(1 + 2, 3 * 4) -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atExpressionStart.kt.after.k2 b/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atExpressionStart.kt.after.k2 deleted file mode 100644 index 4c9ffa388d2b..000000000000 --- a/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atExpressionStart.kt.after.k2 +++ /dev/null @@ -1,6 +0,0 @@ -// AFTER-WARNING: Variable 'foo' is never used -fun foo(a: Int, b: Int) = a + b - -fun foo() { - val foo = foo(1 + 2, 3 * 4) -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atNestedExpression.kt.after.k2 b/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atNestedExpression.kt.after.k2 deleted file mode 100644 index 4c9ffa388d2b..000000000000 --- a/plugins/kotlin/idea/tests/testData/intentions/introduceVariable/atNestedExpression.kt.after.k2 +++ /dev/null @@ -1,6 +0,0 @@ -// AFTER-WARNING: Variable 'foo' is never used -fun foo(a: Int, b: Int) = a + b - -fun foo() { - val foo = foo(1 + 2, 3 * 4) -} \ No newline at end of file diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableHandler.kt b/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableHandler.kt index 972cef4752bd..facf588acf64 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableHandler.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableHandler.kt @@ -219,7 +219,7 @@ object K2IntroduceVariableHandler : KotlinIntroduceVariableHandler() { } } - val isInplaceAvailable = editor != null + val isInplaceAvailable = isInplaceAvailable(editor, project) val allOccurrences = occurrencesToReplace ?: expression.findOccurrences(containers.occurrenceContainer)