Move to Companion Intention: Do not use qualified names as labels

#KT-11483 Fixed
This commit is contained in:
Alexey Sedunov
2016-08-31 17:51:07 +03:00
parent 78a4e90132
commit 23491afde2
5 changed files with 33 additions and 1 deletions
+1
View File
@@ -110,6 +110,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
#### 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-11483`](https://youtrack.jetbrains.com/issue/KT-11483) Move to Companion: Do not use qualified names as labels
##### New features
@@ -135,7 +135,7 @@ class MoveMemberToCompanionObjectIntention : SelfTargetingRangeIntention<KtNamed
val receiver = call.getQualifiedExpressionForSelector()?.receiverExpression
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())
}
}
@@ -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);
}
@TestMetadata("doNotQualifyThisLabel.kt")
public void testDoNotQualifyThisLabel() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveToCompanion/doNotQualifyThisLabel.kt");
doTest(fileName);
}
@TestMetadata("dropFinal.kt")
public void testDropFinal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveToCompanion/dropFinal.kt");