Smart completion when only named argument possible
This commit is contained in:
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.utils.sure
|
||||
// resolved call
|
||||
|
||||
public fun <D : CallableDescriptor> ResolvedCall<D>.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 <D : CallableDescriptor> ResolvedCall<D>.hasUnmappedArguments(): Boolean {
|
||||
|
||||
@@ -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())
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
fun foo(param1: String, param2: Int, param3: Char) { }
|
||||
|
||||
fun bar(pInt: Int, pString: String) {
|
||||
foo(param2 = , <caret>)
|
||||
}
|
||||
|
||||
// EXIST: { lookupString: "param1", itemText: "param1 =" }
|
||||
// EXIST: { lookupString: "param3", itemText: "param3 =" }
|
||||
// ABSENT: param2
|
||||
// NUMBER: 2
|
||||
@@ -0,0 +1,10 @@
|
||||
fun foo(param1: String, param2: Int, param3: Char) { }
|
||||
|
||||
fun bar(pInt: Int, pString: String) {
|
||||
foo(param2 = 1, <caret>)
|
||||
}
|
||||
|
||||
// EXIST: { lookupString: "param1", itemText: "param1 =" }
|
||||
// EXIST: { lookupString: "param3", itemText: "param3 =" }
|
||||
// ABSENT: param2
|
||||
// NUMBER: 2
|
||||
+12
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user