diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/K1IntroduceVariableHandler.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/K1IntroduceVariableHandler.kt index eb0b0bbe7f4b..a06a05357730 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/K1IntroduceVariableHandler.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/K1IntroduceVariableHandler.kt @@ -104,7 +104,7 @@ object K1IntroduceVariableHandler : KotlinIntroduceVariableHandler() { ConvertToBlockBodyIntention.Holder.convert(declaration) } - fun KtExpression.findOccurrences(occurrenceContainer: PsiElement): List = + override fun KtExpression.findOccurrences(occurrenceContainer: KtElement): List = toRange().match(occurrenceContainer, KotlinPsiUnifier.DEFAULT).mapNotNull { val candidate = it.range.elements.first() diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableServiceK1Impl.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableServiceK1Impl.kt index 79f61eb23fad..336bb592863b 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableServiceK1Impl.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableServiceK1Impl.kt @@ -58,7 +58,7 @@ internal class KotlinIntroduceVariableServiceK1Impl(private val project: Project override fun findOccurrences( expression: KtExpression, - occurrenceContainer: PsiElement + occurrenceContainer: KtElement ): List = with(K1IntroduceVariableHandler) { expression.findOccurrences(occurrenceContainer) } diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FewOccurrences.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FewOccurrences.kt index f6c88168cdee..185be4fa9976 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FewOccurrences.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FewOccurrences.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a() { 1 1 diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FewOccurrences.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FewOccurrences.kt.after index d73e18e2de97..3ba0cd582489 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FewOccurrences.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FewOccurrences.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a() { val i = 1 i diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FromLambda.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FromLambda.kt index b07658d0be76..cecb7e9a7631 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FromLambda.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FromLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun foo() { val z = 123 val x: (Int) -> Int = { 123} diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FromLambda.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FromLambda.kt.after index 462d170ba745..9b8812d32284 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FromLambda.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FromLambda.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun foo() { val i = 123 val z = i diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FunctionAddBlockInner.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FunctionAddBlockInner.kt index edf21ea2082e..6d65b432f02d 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FunctionAddBlockInner.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FunctionAddBlockInner.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun foo(a: Int) = if (a > 1) { (a + 1) * (a - 1) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FunctionAddBlockInner.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FunctionAddBlockInner.kt.after index 4cbafb645a5e..8e07278b67e5 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FunctionAddBlockInner.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/FunctionAddBlockInner.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun foo(a: Int): Int { val i = a + 1 return if (a > 1) { diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyInnerOccurences.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyInnerOccurences.kt index 54c63ea36f2a..b7050f49943d 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyInnerOccurences.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyInnerOccurences.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a() { if (true) { if (true) { diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyInnerOccurences.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyInnerOccurences.kt.after index 5b5d63e8cc4b..388d5829534c 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyInnerOccurences.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyInnerOccurences.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a() { val i = 1 if (true) { diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrences.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrences.kt index f93e60113e3f..93b778c07034 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrences.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrences.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a() { if (true) { 1 diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrences.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrences.kt.after index cf04313d3608..341b9b7fb3eb 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrences.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrences.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a() { val i = 1 if (true) { diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrencesInSingleContainer.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrencesInSingleContainer.kt index b1a6cece7dc4..46c0ee803e5f 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrencesInSingleContainer.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrencesInSingleContainer.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun test() { 1 1 diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrencesInSingleContainer.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrencesInSingleContainer.kt.after index 42cb7ef7a643..f84fa8f1d036 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrencesInSingleContainer.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/ManyOccurrencesInSingleContainer.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun test() { val i = 1 i diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OccurrencesInStringTemplate.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OccurrencesInStringTemplate.kt index 2413b997da01..084f4521aec0 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OccurrencesInStringTemplate.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OccurrencesInStringTemplate.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a(x: Int) { val a = x + 1 "it's a number ${x + 1}" diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OccurrencesInStringTemplate.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OccurrencesInStringTemplate.kt.after index b5e603fb25e1..2abba0a9a67e 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OccurrencesInStringTemplate.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OccurrencesInStringTemplate.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a(x: Int) { val i = x + 1 val a = i diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OneExplicitReceiver.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OneExplicitReceiver.kt index 3fa7e5e31a6b..a1d5d227d817 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OneExplicitReceiver.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OneExplicitReceiver.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun main(args: Array) { val myA = A() println(myA.prop) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OneExplicitReceiver.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OneExplicitReceiver.kt.after index 8482bc640908..7e497ed639a5 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OneExplicitReceiver.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/OneExplicitReceiver.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun main(args: Array) { val myA = A() val prop = myA.prop diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/PropertyAccessorAddBlockInner.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/PropertyAccessorAddBlockInner.kt index d3e4653ae3b2..f66a356075a4 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/PropertyAccessorAddBlockInner.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/PropertyAccessorAddBlockInner.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 val a = 2 val x: Int get() = diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/PropertyAccessorAddBlockInner.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/PropertyAccessorAddBlockInner.kt.after index d883aaa9ddaa..e1e61f518d64 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/PropertyAccessorAddBlockInner.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/PropertyAccessorAddBlockInner.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 val a = 2 val x: Int get() { diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/TwoExplicitReceivers.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/TwoExplicitReceivers.kt index b6e71db3fc3d..2bebed4dcc77 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/TwoExplicitReceivers.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/TwoExplicitReceivers.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 class Bar { } diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/TwoExplicitReceivers.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/TwoExplicitReceivers.kt.after index cedba030300b..99e07bc620fa 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/TwoExplicitReceivers.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/TwoExplicitReceivers.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 class Bar { } diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UnresolvedOccurrences.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UnresolvedOccurrences.kt index d31821196381..ad3b5a78131f 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UnresolvedOccurrences.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UnresolvedOccurrences.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a() { val x = Foo() println(Foo()) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UnresolvedOccurrences.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UnresolvedOccurrences.kt.after index 035b5e9b0705..98f1e7e38925 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UnresolvedOccurrences.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UnresolvedOccurrences.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a() { val foo = Foo() val x = foo diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions1.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions1.kt index 39e8dbd1d1b3..ab077808f58e 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions1.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions1.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 class A { fun test() = 1 } diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions1.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions1.kt.after index 4044132830cc..1b27d16c37f8 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions1.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions1.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 class A { fun test() = 1 } diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions2.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions2.kt index 60d80d138144..0fca55b8a35e 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions2.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions2.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 class A { fun test() = 1 } diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions2.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions2.kt.after index 4044132830cc..1b27d16c37f8 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions2.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/UsedAndUnusedExpressions2.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 class A { fun test() = 1 } diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/WhenParts.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/WhenParts.kt index 04a2ca47a263..d9ac159674ef 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/WhenParts.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/WhenParts.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a() { when (1) { is 3 -> 1 diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/WhenParts.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/WhenParts.kt.after index 894f37dbdf02..86f2fa82d6ee 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/WhenParts.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/WhenParts.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun a() { val i = 1 when (i) { diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/arrayAssignment.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/arrayAssignment.kt index 05597988eef1..9f7ad9dce8c9 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/arrayAssignment.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/arrayAssignment.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 // WITH_STDLIB class Foo(var bar: IntArray) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/arrayAssignment.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/arrayAssignment.kt.after index 31d46e87ddf1..be45b58b0e1a 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/arrayAssignment.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/arrayAssignment.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 // WITH_STDLIB class Foo(var bar: IntArray) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/callUnderSmartCast.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/callUnderSmartCast.kt index cf61259e3b8c..fcd6ac133101 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/callUnderSmartCast.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/callUnderSmartCast.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 interface T { fun foo(): Int } diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/callUnderSmartCast.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/callUnderSmartCast.kt.after index 9d18af74cd71..e10c8ea4f643 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/callUnderSmartCast.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/callUnderSmartCast.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 interface T { fun foo(): Int } diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/explicateTypeArguments/Parenthesized.kt.fir.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/explicateTypeArguments/Parenthesized.kt.fir.after deleted file mode 100644 index 838c29d18c8f..000000000000 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/explicateTypeArguments/Parenthesized.kt.fir.after +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_STDLIB -fun f() { - val listOf = listOf() - val v : List = (listOf) -} diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideFunExpression.kt.fir.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideFunExpression.kt.fir.after deleted file mode 100644 index b4d3af550370..000000000000 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideFunExpression.kt.fir.after +++ /dev/null @@ -1,6 +0,0 @@ -fun foo(f: () -> Int) { } - -fun test() { - val i = 1 + 2 - foo(fun() = (i) * 3) -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideFunExpressionWithBlock.kt.fir.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideFunExpressionWithBlock.kt.fir.after deleted file mode 100644 index b875b79fa2a9..000000000000 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideFunExpressionWithBlock.kt.fir.after +++ /dev/null @@ -1,6 +0,0 @@ -fun foo(f: () -> Int) { } - -fun test() { - val i = 1 + 2 - foo(fun(): Int { return (i) * 3 }) -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideLamba.kt.fir.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideLamba.kt.fir.after deleted file mode 100644 index 88ee0163be91..000000000000 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideLamba.kt.fir.after +++ /dev/null @@ -1,6 +0,0 @@ -fun foo(f: () -> Int) { } - -fun test() { - val i = 1 + 2 - foo { (i) * 3 } -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedFunExpression.kt.fir.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedFunExpression.kt.fir.after deleted file mode 100644 index bd3026d7c29c..000000000000 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedFunExpression.kt.fir.after +++ /dev/null @@ -1,6 +0,0 @@ -fun foo(f: () -> Int) = f() - -fun test() { - val i = 1 + 2 - foo(fun() = foo(fun() = (i) * 3)) -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedFunExpressionInLambda.kt.fir.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedFunExpressionInLambda.kt.fir.after deleted file mode 100644 index 0249fa7a5630..000000000000 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedFunExpressionInLambda.kt.fir.after +++ /dev/null @@ -1,6 +0,0 @@ -fun foo(f: () -> Int) = f() - -fun test() { - val i = 1 + 2 - foo { foo(fun() = (i) * 3) } -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedLamba.kt.fir.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedLamba.kt.fir.after deleted file mode 100644 index 246b1efd3441..000000000000 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedLamba.kt.fir.after +++ /dev/null @@ -1,6 +0,0 @@ -fun foo(f: () -> Int) = f() - -fun test() { - val i = 1 + 2 - foo { foo { (i) * 3 } } -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedLambdaInFunExpression.kt.fir.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedLambdaInFunExpression.kt.fir.after deleted file mode 100644 index 809ae641850c..000000000000 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/extractToScope/insideNestedLambdaInFunExpression.kt.fir.after +++ /dev/null @@ -1,6 +0,0 @@ -fun foo(f: () -> Int) = f() - -fun test() { - val i = 1 + 2 - foo(fun() = foo { (i) * 3 }) -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withConstructorParam.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withConstructorParam.kt index 0dc34c4ecf52..7bf97b73735f 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withConstructorParam.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withConstructorParam.kt @@ -1,4 +1,4 @@ -// IGNORE_K2 +// INPLACE_VARIABLE_NAME: test1 fun test() = "123" open class First(val s: String) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withConstructorParam.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withConstructorParam.kt.after index 0b51b0d5928e..37e8ffb9ac00 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withConstructorParam.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withConstructorParam.kt.after @@ -1,4 +1,4 @@ -// IGNORE_K2 +// INPLACE_VARIABLE_NAME: test1 fun test() = "123" open class First(val s: String) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withGlobal.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withGlobal.kt index 80bf2865de85..0fa73cc424e1 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withGlobal.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withGlobal.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun test() = "123" val f = test() + "456" diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withGlobal.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withGlobal.kt.after index 8e0f292757e5..e54647b94647 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withGlobal.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withGlobal.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun test() = "123" val test = test() diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withParam.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withParam.kt index 386b81dca60a..58a7ee72b2b7 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withParam.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withParam.kt @@ -1,4 +1,4 @@ -// IGNORE_K2 +// INPLACE_VARIABLE_NAME: test1 fun test() = "123" val f = test() + "456" diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withParam.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withParam.kt.after index b2419ae7eff5..38490f9d81f6 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withParam.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/kt21530_withParam.kt.after @@ -1,4 +1,4 @@ -// IGNORE_K2 +// INPLACE_VARIABLE_NAME: test1 fun test() = "123" val test1 = test() diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/multiDeclarations/usedExpr.kt.fir.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/multiDeclarations/usedExpr.kt.fir.after deleted file mode 100644 index 7bc026bee7b8..000000000000 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/multiDeclarations/usedExpr.kt.fir.after +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_STDLIB -fun test() { - val pair = 1 to 2 - (pair).first -} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/notNullAssertion.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/notNullAssertion.kt index 58a54a47fad9..37e329287119 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/notNullAssertion.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/notNullAssertion.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun foo(): Int { val s: String? = "" return if (true) { diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/notNullAssertion.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/notNullAssertion.kt.after index 394ce5881977..624798a3c5dc 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/notNullAssertion.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/notNullAssertion.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun foo(): Int { val s: String? = "" val length = s!!.length diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/script/ExpressionPart.kts b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/script/ExpressionPart.kts index f90e08da0a0b..1625c61f8f9d 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/script/ExpressionPart.kts +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/script/ExpressionPart.kts @@ -1,3 +1,2 @@ -// IGNORE_K2 1 + 2 2 + 3 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/script/ExpressionPart.kts.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/script/ExpressionPart.kts.after index f956432088d3..e260b613b081 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/script/ExpressionPart.kts.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/script/ExpressionPart.kts.after @@ -1,4 +1,3 @@ -// IGNORE_K2 val i = 2 1 + i i + 3 diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/selectorAssignment.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/selectorAssignment.kt index c677d3aa2ba7..a8cbaa287c17 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/selectorAssignment.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/selectorAssignment.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 // WITH_STDLIB class Foo(var bar: Bar) class Bar(var baz: Int) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/selectorAssignment.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/selectorAssignment.kt.after index 9cd897621d9b..493116c439a3 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/selectorAssignment.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/selectorAssignment.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 // WITH_STDLIB class Foo(var bar: Bar) class Bar(var baz: Int) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/skipUsageInAssignmentLHS.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/skipUsageInAssignmentLHS.kt index ad0392b3b8a4..598db6b807e9 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/skipUsageInAssignmentLHS.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/skipUsageInAssignmentLHS.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 // WITH_STDLIB class Foo(var bar: Int) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/skipUsageInAssignmentLHS.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/skipUsageInAssignmentLHS.kt.after index 7cf6cc08e79c..55e5776e4f63 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/skipUsageInAssignmentLHS.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/skipUsageInAssignmentLHS.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 // WITH_STDLIB class Foo(var bar: Int) diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullContent.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullContent.kt index 9e315729f7e7..5907fb5634ef 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullContent.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullContent.kt @@ -1,4 +1,4 @@ -// IGNORE_K2 +// INPLACE_VARIABLE_NAME: s fun foo(a: Int): String { val x = "abc$a" val y = "abc${a}" diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullContent.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullContent.kt.after index 5eec135d03c2..9c170f4c297e 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullContent.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullContent.kt.after @@ -1,4 +1,4 @@ -// IGNORE_K2 +// INPLACE_VARIABLE_NAME: s fun foo(a: Int): String { val s = "abc$a" val x = s diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithBlockExpr.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithBlockExpr.kt index e66d93bcc50c..2a19834a5bc6 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithBlockExpr.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithBlockExpr.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun foo(a: Int): String { val x = "-${a + 1}" val y = "x${a + 1}y" diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithBlockExpr.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithBlockExpr.kt.after index 3ba7978ab5d3..920ba830a215 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithBlockExpr.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithBlockExpr.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun foo(a: Int): String { val i = a + 1 val x = "-$i" diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithSimpleName.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithSimpleName.kt index b75a5e21ff4d..b3e5ea58080b 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithSimpleName.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithSimpleName.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun foo(a: Int): String { val x = "-$a" val y = "x${a}y" diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithSimpleName.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithSimpleName.kt.after index 7c76d4b00e0e..60d242b3bb83 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithSimpleName.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/stringTemplates/fullEntryWithSimpleName.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun foo(a: Int): String { val a1 = a val x = "-$a1" diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/thisAsCallee.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/thisAsCallee.kt index cd6fd74df314..2269f2e55d23 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/thisAsCallee.kt +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/thisAsCallee.kt @@ -1,4 +1,3 @@ -// IGNORE_K2 fun (String.() -> String).foo(x : String) { x.this() x.this@foo() diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/thisAsCallee.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/thisAsCallee.kt.after index 9a133d11b1f2..1cc8d17a0e45 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/thisAsCallee.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/thisAsCallee.kt.after @@ -1,4 +1,3 @@ -// IGNORE_K2 fun (String.() -> String).foo(x : String) { val function = this x.function() diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableHandler.kt b/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableHandler.kt index 1bf57c497786..9951a11d9fd8 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableHandler.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableHandler.kt @@ -62,6 +62,8 @@ abstract class KotlinIntroduceVariableHandler : RefactoringActionHandler { onNonInteractiveFinish: ((KtDeclaration) -> Unit)? = null, ) + abstract fun KtExpression.findOccurrences(occurrenceContainer: KtElement): List + /** * @param contained expression, which is: * * parent of extracted expression before refactoring diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableService.kt b/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableService.kt index b39ff9defe81..145217bb4fe0 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableService.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableService.kt @@ -20,7 +20,7 @@ interface KotlinIntroduceVariableService { ): PsiElement? fun getContainersForExpression(expression: KtExpression): List - fun findOccurrences(expression: KtExpression, occurrenceContainer: PsiElement): List + fun findOccurrences(expression: KtExpression, occurrenceContainer: KtElement): List fun doRefactoringWithContainer( editor: Editor?, diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.introduce.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableHandler.kt b/plugins/kotlin/refactorings/kotlin.refactorings.introduce.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableHandler.kt index 3c12b5507b21..521138211853 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.introduce.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableHandler.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.introduce.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableHandler.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.idea.codeinsight.utils.ConvertToBlockBodyUtils import org.jetbrains.kotlin.idea.codeinsight.utils.NamedArgumentUtils import org.jetbrains.kotlin.idea.codeinsight.utils.addTypeArguments import org.jetbrains.kotlin.idea.codeinsight.utils.getRenderedTypeArguments +import org.jetbrains.kotlin.idea.k2.refactoring.introduce.K2SemanticMatcher import org.jetbrains.kotlin.idea.refactoring.KotlinCommonRefactoringSettings import org.jetbrains.kotlin.idea.refactoring.introduce.KotlinIntroduceVariableContext import org.jetbrains.kotlin.idea.refactoring.introduce.KotlinIntroduceVariableHandler @@ -208,7 +209,8 @@ object K2IntroduceVariableHandler : KotlinIntroduceVariableHandler() { val isInplaceAvailable = editor != null - val allOccurrences = listOf(expression) // TODO: KTIJ-27861 + val allOccurrences = occurrencesToReplace ?: expression.findOccurrences(containers.occurrenceContainer) + val callback = Pass.create { replaceChoice: OccurrencesChooser.ReplaceChoice -> val allReplaces = when (replaceChoice) { OccurrencesChooser.ReplaceChoice.ALL -> allOccurrences @@ -345,6 +347,19 @@ object K2IntroduceVariableHandler : KotlinIntroduceVariableHandler() { } } + override fun KtExpression.findOccurrences(occurrenceContainer: KtElement): List = + analyzeInModalWindow(contextElement = this, KotlinBundle.message("find.usages.prepare.dialog.progress")) { + K2SemanticMatcher.findMatches(patternElement = this@findOccurrences, scopeElement = occurrenceContainer) + .filterNot { it.isAssignmentLHS() } + .mapNotNull { match -> + when (match) { + is KtExpression -> match + is KtStringTemplateEntryWithExpression -> match.expression + else -> errorWithAttachment("Unexpected candidate element ${match::class.java}") { withPsiEntry("match", match) } + } + } + }.ifEmpty { listOf(this) } + private fun areTypeArgumentsNeededForCorrectTypeInference(expression: KtExpression): Boolean { val call = expression.getPossiblyQualifiedCallExpression() ?: return false if (call.typeArgumentList != null) return false diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.introduce.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/KotlinIntroduceVariableServiceK2Impl.kt b/plugins/kotlin/refactorings/kotlin.refactorings.introduce.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/KotlinIntroduceVariableServiceK2Impl.kt index 05c2ba333fd6..fe83c352ed74 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.introduce.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/KotlinIntroduceVariableServiceK2Impl.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.introduce.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/KotlinIntroduceVariableServiceK2Impl.kt @@ -45,8 +45,10 @@ internal class KotlinIntroduceVariableServiceK2Impl(private val project: Project override fun findOccurrences( expression: KtExpression, - occurrenceContainer: PsiElement - ): List = listOf(expression) + occurrenceContainer: KtElement, + ): List = with(K2IntroduceVariableHandler) { + expression.findOccurrences(occurrenceContainer) + } override fun doRefactoringWithContainer( editor: Editor?,