Move to Companion Intention: Do not use qualified names as labels
#KT-11483 Fixed
This commit is contained in:
@@ -110,6 +110,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
|||||||
#### Intention actions, inspections and quickfixes
|
#### Intention actions, inspections and quickfixes
|
||||||
|
|
||||||
- [`KT-9490`](https://youtrack.jetbrains.com/issue/KT-9490) Convert receiver to parameter: use template instead of the dialog
|
- [`KT-9490`](https://youtrack.jetbrains.com/issue/KT-9490) Convert receiver to parameter: use template instead of the dialog
|
||||||
|
- [`KT-11483`](https://youtrack.jetbrains.com/issue/KT-11483) Move to Companion: Do not use qualified names as labels
|
||||||
|
|
||||||
##### New features
|
##### New features
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -135,7 +135,7 @@ class MoveMemberToCompanionObjectIntention : SelfTargetingRangeIntention<KtNamed
|
|||||||
|
|
||||||
val receiver = call.getQualifiedExpressionForSelector()?.receiverExpression
|
val receiver = call.getQualifiedExpressionForSelector()?.receiverExpression
|
||||||
val receiverArg = receiver?.let { psiFactory.createArgument(it) }
|
val receiverArg = receiver?.let { psiFactory.createArgument(it) }
|
||||||
?: psiFactory.createArgument(psiFactory.createExpression("this@${classFqName.asString()}"))
|
?: psiFactory.createArgument(psiFactory.createExpression("this@${classFqName.shortName().asString()}"))
|
||||||
argumentList.addArgumentBefore(receiverArg, argumentList.arguments.firstOrNull())
|
argumentList.addArgumentBefore(receiverArg, argumentList.arguments.firstOrNull())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
package foo
|
||||||
|
|
||||||
|
class InsertThis {
|
||||||
|
val v1 = 1
|
||||||
|
fun <caret>f() {
|
||||||
|
println(v1)
|
||||||
|
}
|
||||||
|
fun use() { f() }
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
package foo
|
||||||
|
|
||||||
|
class InsertThis {
|
||||||
|
val v1 = 1
|
||||||
|
fun use() {
|
||||||
|
Companion.f(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun f(insertThis: InsertThis) {
|
||||||
|
println(insertThis.v1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9001,6 +9001,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/moveToCompanion"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/moveToCompanion"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("doNotQualifyThisLabel.kt")
|
||||||
|
public void testDoNotQualifyThisLabel() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveToCompanion/doNotQualifyThisLabel.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("dropFinal.kt")
|
@TestMetadata("dropFinal.kt")
|
||||||
public void testDropFinal() throws Exception {
|
public void testDropFinal() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveToCompanion/dropFinal.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveToCompanion/dropFinal.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user