Support mixed positioned/named arguments in AddNameToArgumentIntention
^KT-7745 Fixed
This commit is contained in:
@@ -42,7 +42,10 @@ class AddNameToArgumentIntention : SelfTargetingIntention<KtValueArgument>(
|
||||
|
||||
override fun isApplicableTo(element: KtValueArgument, caretOffset: Int): Boolean {
|
||||
val expression = element.getArgumentExpression() ?: return false
|
||||
val name = detectNameToAdd(element, shouldBeLastUnnamed = true) ?: return false
|
||||
val name = detectNameToAdd(
|
||||
element,
|
||||
shouldBeLastUnnamed = !element.languageVersionSettings.supportsFeature(LanguageFeature.MixedNamedArgumentsInTheirOwnPosition)
|
||||
) ?: return false
|
||||
|
||||
text = "Add '$name =' to argument"
|
||||
|
||||
@@ -110,4 +113,4 @@ class AddNameToArgumentIntention : SelfTargetingIntention<KtValueArgument>(
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// COMPILER_ARGUMENTS: -XXLanguage:+NewInference -XXLanguage:+MixedNamedArgumentsInTheirOwnPosition
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(s: String, b: Boolean){}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>"", true)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// COMPILER_ARGUMENTS: -XXLanguage:+NewInference -XXLanguage:+MixedNamedArgumentsInTheirOwnPosition
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(s: String, b: Boolean){}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>s = "", true)
|
||||
}
|
||||
@@ -1216,6 +1216,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
runTest("idea/testData/intentions/addNameToArgument/linkedList.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mixingPositionedAndNamed.kt")
|
||||
public void testMixingPositionedAndNamed() throws Exception {
|
||||
runTest("idea/testData/intentions/addNameToArgument/mixingPositionedAndNamed.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notInsideIndices.kt")
|
||||
public void testNotInsideIndices() throws Exception {
|
||||
runTest("idea/testData/intentions/addNameToArgument/notInsideIndices.kt");
|
||||
|
||||
Reference in New Issue
Block a user