diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt index 94e5cf2acf2..25215d6ec3c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.utils.sure // resolved call public fun ResolvedCall.noErrorsInValueArguments(): Boolean { - return getCall().getValueArguments().all { argument -> !getArgumentMapping(argument!!).isError() } + return getCall().getValueArguments().all { argument -> argument.getArgumentExpression() != null/* isError() crashes otherwise!*/ && !getArgumentMapping(argument!!).isError() } } public fun ResolvedCall.hasUnmappedArguments(): Boolean { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 032638ca5ac..c662a2fb6f7 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -399,6 +399,11 @@ class SmartCompletionSession(configuration: CompletionSessionConfiguration, para private val DESCRIPTOR_KIND_MASK = DescriptorKindFilter.VALUES exclude SamConstructorDescriptorKindExclude override fun doComplete() { + if (NamedParametersCompletion.isOnlyNamedParameterExpected(position)) { + NamedParametersCompletion.complete(position, collector, bindingContext) + return + } + if (expression != null) { val mapper = ToFromOriginalFileMapper(parameters.getOriginalFile() as JetFile, position.getContainingFile() as JetFile, parameters.getOffset()) diff --git a/idea/idea-completion/testData/smart/AfterEmptyArgument.kt b/idea/idea-completion/testData/smart/AfterEmptyArgument.kt new file mode 100644 index 00000000000..c2cc89cb9e3 --- /dev/null +++ b/idea/idea-completion/testData/smart/AfterEmptyArgument.kt @@ -0,0 +1,10 @@ +fun foo(param1: String, param2: Int, param3: Char) { } + +fun bar(pInt: Int, pString: String) { + foo(param2 = , ) +} + +// EXIST: { lookupString: "param1", itemText: "param1 =" } +// EXIST: { lookupString: "param3", itemText: "param3 =" } +// ABSENT: param2 +// NUMBER: 2 diff --git a/idea/idea-completion/testData/smart/AfterNamedArgument.kt b/idea/idea-completion/testData/smart/AfterNamedArgument.kt new file mode 100644 index 00000000000..ddb346edfe0 --- /dev/null +++ b/idea/idea-completion/testData/smart/AfterNamedArgument.kt @@ -0,0 +1,10 @@ +fun foo(param1: String, param2: Int, param3: Char) { } + +fun bar(pInt: Int, pString: String) { + foo(param2 = 1, ) +} + +// EXIST: { lookupString: "param1", itemText: "param1 =" } +// EXIST: { lookupString: "param3", itemText: "param3 =" } +// ABSENT: param2 +// NUMBER: 2 diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java index 7cb22c37739..ef7b765ae1f 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java @@ -31,12 +31,24 @@ import java.util.regex.Pattern; @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionTest { + @TestMetadata("AfterEmptyArgument.kt") + public void testAfterEmptyArgument() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smart/AfterEmptyArgument.kt"); + doTest(fileName); + } + @TestMetadata("AfterExclSign.kt") public void testAfterExclSign() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smart/AfterExclSign.kt"); doTest(fileName); } + @TestMetadata("AfterNamedArgument.kt") + public void testAfterNamedArgument() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smart/AfterNamedArgument.kt"); + doTest(fileName); + } + public void testAllFilesPresentInSmart() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/smart"), Pattern.compile("^(.+)\\.kt$"), true); }