Fix "make constructor parameter a property" for vararg case

Same should work for annotated parameters
#KT-29312 Fixed
This commit is contained in:
Mikhail Glukhikh
2019-03-04 12:32:48 +03:00
parent c714e599ea
commit 9e2ee6183c
4 changed files with 20 additions and 1 deletions
@@ -46,7 +46,7 @@ class MakeConstructorParameterPropertyFix(
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
element.addBefore(kotlinValVar.createKeyword(KtPsiFactory(project))!!, element.firstChild)
element.addBefore(kotlinValVar.createKeyword(KtPsiFactory(project))!!, element.nameIdentifier)
element.addModifier(KtTokens.PRIVATE_KEYWORD)
element.visibilityModifier()?.let { private ->
editor?.apply {
@@ -0,0 +1,7 @@
// "Make constructor parameter a property" "true"
class SomeClass(vararg dismissibleViewTypes: Int) {
fun someFun() {
<caret>dismissibleViewTypes
}
}
@@ -0,0 +1,7 @@
// "Make constructor parameter a property" "true"
class SomeClass(private vararg val dismissibleViewTypes: Int) {
fun someFun() {
dismissibleViewTypes
}
}
@@ -7709,6 +7709,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
public void testVar() throws Exception {
runTest("idea/testData/quickfix/makeConstructorParameterProperty/var.kt");
}
@TestMetadata("vararg.kt")
public void testVararg() throws Exception {
runTest("idea/testData/quickfix/makeConstructorParameterProperty/vararg.kt");
}
}
@TestMetadata("idea/testData/quickfix/makeTypeParameterReified")