KT-18979 Add val to proper place for 'Add val/var' intent

This commit is contained in:
Andrius Semionovas
2017-07-12 21:05:57 +03:00
committed by asedunov
parent f01de3a935
commit 1cab0d09ab
4 changed files with 15 additions and 1 deletions
@@ -46,7 +46,7 @@ interface AddValVarToConstructorParameterAction {
fun invoke(element: KtParameter, editor: Editor?) {
val project = element.project
element.addAfter(KtPsiFactory(project).createValKeyword(), null)
element.addBefore(KtPsiFactory(project).createValKeyword(), element.nameIdentifier)
if (editor == null) return
+4
View File
@@ -0,0 +1,4 @@
// "Add val/var to parameter 'x'" "true"
class Foo(vararg <caret>x: Int, val y: Int) {
}
@@ -0,0 +1,4 @@
// "Add val/var to parameter 'x'" "true"
class Foo(vararg val<caret> x: Int, val y: Int) {
}
@@ -793,6 +793,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
doTest(fileName);
}
@TestMetadata("addValAfterVarArg.kt")
public void testAddValAfterVarArg() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addValVar/addValAfterVarArg.kt");
doTest(fileName);
}
public void testAllFilesPresentInAddValVar() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/addValVar"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
}