Add name to argument intention to work not only on the last argument
This commit is contained in:
@@ -62,7 +62,7 @@ public class AddNameToArgumentIntention
|
||||
if (argument is JetFunctionLiteralArgument) return null
|
||||
|
||||
val argumentList = argument.getParent() as? JetValueArgumentList ?: return null
|
||||
if (argument != argumentList.getArguments().last()) return null
|
||||
if (argument != argumentList.arguments.last { !it.isNamed() }) return null
|
||||
|
||||
val callExpr = argumentList.getParent() as? JetExpression ?: return null
|
||||
val resolvedCall = callExpr.getResolvedCall(callExpr.analyze(BodyResolveMode.PARTIAL)) ?: return null
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// INTENTION_TEXT: "Add 'a =' to argument"
|
||||
|
||||
fun foo(a: Int, b: String){}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>1, b = "")
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// INTENTION_TEXT: "Add 'a =' to argument"
|
||||
|
||||
fun foo(a: Int, b: String){}
|
||||
|
||||
fun bar() {
|
||||
foo(a = 1, b = "")
|
||||
}
|
||||
@@ -199,6 +199,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeOtherNamed.kt")
|
||||
public void testBeforeOtherNamed() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addNameToArgument/beforeOtherNamed.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("functionLiteralArgument.kt")
|
||||
public void testFunctionLiteralArgument() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addNameToArgument/functionLiteralArgument.kt");
|
||||
|
||||
Reference in New Issue
Block a user