Add name to argument intention to work not only on the last argument

This commit is contained in:
Valentin Kipyatkov
2015-08-19 21:00:27 +03:00
parent 5e1d8bc503
commit ba33c834c1
4 changed files with 21 additions and 1 deletions
@@ -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");