mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Extract variable: choose class body as container when introducing class property and replacing all occurrences
^KTIJ-9043 Fixed ^KTIJ-14455 Fixed GitOrigin-RevId: cabc4ee5ad81253f9f51dedfe072a54c9b18923a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e75f89a4f7
commit
bda0682dc8
+10
@@ -872,6 +872,16 @@ public abstract class ExtractionTestGenerated extends AbstractExtractionTest {
|
||||
runTest("testData/refactoring/introduceVariable/javaInnerClassQualifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("KTIJ-14455.kt")
|
||||
public void testKTIJ_14455() throws Exception {
|
||||
runTest("testData/refactoring/introduceVariable/KTIJ-14455.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("KTIJ-9043.kt")
|
||||
public void testKTIJ_9043() throws Exception {
|
||||
runTest("testData/refactoring/introduceVariable/KTIJ-9043.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt10808.kt")
|
||||
public void testKt10808() throws Exception {
|
||||
runTest("testData/refactoring/introduceVariable/kt10808.kt");
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class X {
|
||||
val s0 = ""
|
||||
val s1 = <selection>s0.substring(0)</selection>
|
||||
val s2 = s0.substring(0)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class X {
|
||||
val s0 = ""
|
||||
val substring = s0.substring(0)
|
||||
val s1 = substring
|
||||
val s2 = substring
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
val bar = <selection>0</selection>
|
||||
val baz = 0
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
val i = 0
|
||||
val bar = i
|
||||
val baz = i
|
||||
}
|
||||
+1
-1
@@ -217,7 +217,7 @@ abstract class KotlinIntroduceVariableHandler : RefactoringActionHandler {
|
||||
}
|
||||
|
||||
fun KtElement.getContainer(): KtElement? {
|
||||
if (this is KtBlockExpression) return this
|
||||
if (this is KtBlockExpression || this is KtClassBody) return this
|
||||
|
||||
return (parentsWithSelf.zip(parents)).firstOrNull {
|
||||
val (place, parent) = it
|
||||
|
||||
+10
@@ -870,6 +870,16 @@ public abstract class K2IntroduceVariableTestGenerated extends AbstractK2Introdu
|
||||
runTest("../../idea/tests/testData/refactoring/introduceVariable/javaInnerClassQualifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("KTIJ-14455.kt")
|
||||
public void testKTIJ_14455() throws Exception {
|
||||
runTest("../../idea/tests/testData/refactoring/introduceVariable/KTIJ-14455.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("KTIJ-9043.kt")
|
||||
public void testKTIJ_9043() throws Exception {
|
||||
runTest("../../idea/tests/testData/refactoring/introduceVariable/KTIJ-9043.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt10808.kt")
|
||||
public void testKt10808() throws Exception {
|
||||
runTest("../../idea/tests/testData/refactoring/introduceVariable/kt10808.kt");
|
||||
|
||||
Reference in New Issue
Block a user