diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt index e3d494b1274..ef55f433491 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt @@ -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 diff --git a/idea/testData/intentions/addNameToArgument/beforeOtherNamed.kt b/idea/testData/intentions/addNameToArgument/beforeOtherNamed.kt new file mode 100644 index 00000000000..aaf22932789 --- /dev/null +++ b/idea/testData/intentions/addNameToArgument/beforeOtherNamed.kt @@ -0,0 +1,7 @@ +// INTENTION_TEXT: "Add 'a =' to argument" + +fun foo(a: Int, b: String){} + +fun bar() { + foo(1, b = "") +} \ No newline at end of file diff --git a/idea/testData/intentions/addNameToArgument/beforeOtherNamed.kt.after b/idea/testData/intentions/addNameToArgument/beforeOtherNamed.kt.after new file mode 100644 index 00000000000..f8e1bec9143 --- /dev/null +++ b/idea/testData/intentions/addNameToArgument/beforeOtherNamed.kt.after @@ -0,0 +1,7 @@ +// INTENTION_TEXT: "Add 'a =' to argument" + +fun foo(a: Int, b: String){} + +fun bar() { + foo(a = 1, b = "") +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index faa354711af..3c78f9994f8 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -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");