File tree Expand file tree Collapse file tree 4 files changed +15
-0
lines changed
src/org/jetbrains/kotlin/idea/intentions
testData/quickfix/canBePrimaryConstructorProperty
tests/org/jetbrains/kotlin/idea/quickfix Expand file tree Collapse file tree 4 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
32
32
import org.jetbrains.kotlin.idea.util.CommentSaver
33
33
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
34
34
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
35
+ import org.jetbrains.kotlin.lexer.KtTokens.VARARG_KEYWORD
35
36
import org.jetbrains.kotlin.lexer.KtTokens.LATEINIT_KEYWORD
36
37
import org.jetbrains.kotlin.psi.*
37
38
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
@@ -86,6 +87,7 @@ class MovePropertyToConstructorIntention :
86
87
element.modifierList?.getModifiersText()?.let (this ::append)
87
88
propertyAnnotationsText?.takeIf (String ::isNotBlank)?.let { appendWithSpaceBefore(it) }
88
89
parameterAnnotationsText?.let { appendWithSpaceBefore(it) }
90
+ if (constructorParameter.isVarArg) appendWithSpaceBefore(VARARG_KEYWORD .value)
89
91
appendWithSpaceBefore(element.valOrVarKeyword.text)
90
92
element.name?.let { appendWithSpaceBefore(it) }
91
93
constructorParameter.typeReference?.text?.let { append(" : $it " ) }
Original file line number Diff line number Diff line change
1
+ // "Move to constructor" "true"
2
+ class A (vararg strings : String ) {
3
+ val < caret> strings = strings
4
+ }
Original file line number Diff line number Diff line change
1
+ // "Move to constructor" "true"
2
+ class A(vararg val strings: String) {
3
+ }
Original file line number Diff line number Diff line change @@ -1018,6 +1018,12 @@ public void testSimple() throws Exception {
1018
1018
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/canBePrimaryConstructorProperty/simple.kt");
1019
1019
doTest(fileName);
1020
1020
}
1021
+
1022
+ @TestMetadata("vararg.kt")
1023
+ public void testVararg() throws Exception {
1024
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/canBePrimaryConstructorProperty/vararg.kt");
1025
+ doTest(fileName);
1026
+ }
1021
1027
}
1022
1028
1023
1029
@TestMetadata("idea/testData/quickfix/changeSignature")
You can’t perform that action at this time.
0 commit comments