Invoke 'Add name to argument fix' not only on simple name callee expressions
This commit is contained in:
@@ -63,9 +63,6 @@ public class AddNameToArgumentFix extends JetIntentionAction<JetValueArgument> {
|
|||||||
JetCallElement callElement = PsiTreeUtil.getParentOfType(argument, JetCallElement.class);
|
JetCallElement callElement = PsiTreeUtil.getParentOfType(argument, JetCallElement.class);
|
||||||
assert callElement != null : "The argument has to be inside a function or constructor call";
|
assert callElement != null : "The argument has to be inside a function or constructor call";
|
||||||
|
|
||||||
JetExpression callee = callElement.getCalleeExpression();
|
|
||||||
if (!(callee instanceof JetReferenceExpression)) return Collections.emptyList();
|
|
||||||
|
|
||||||
BindingContext context = ResolvePackage.getBindingContext(argument.getContainingJetFile());
|
BindingContext context = ResolvePackage.getBindingContext(argument.getContainingJetFile());
|
||||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(callElement, context);
|
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(callElement, context);
|
||||||
if (resolvedCall == null) return Collections.emptyList();
|
if (resolvedCall == null) return Collections.emptyList();
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// "Add name to argument: 'b = 42'" "true"
|
||||||
|
fun String.invoke(a: Int, b: Int) {}
|
||||||
|
|
||||||
|
fun g() {
|
||||||
|
""(a = 1, b = 42)
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// "Add name to argument: 'b = 42'" "true"
|
||||||
|
fun String.invoke(a: Int, b: Int) {}
|
||||||
|
|
||||||
|
fun g() {
|
||||||
|
""(a = 1, <caret>42)
|
||||||
|
}
|
||||||
@@ -477,6 +477,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/quickfix/checkArguments"), Pattern.compile("^before(\\w+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/quickfix/checkArguments"), Pattern.compile("^before(\\w+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("beforeInvokeOnString.kt")
|
||||||
|
public void testInvokeOnString() throws Exception {
|
||||||
|
doTest("idea/testData/quickfix/checkArguments/beforeInvokeOnString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("beforeMixedNamedAndPositionalArguments.kt")
|
@TestMetadata("beforeMixedNamedAndPositionalArguments.kt")
|
||||||
public void testMixedNamedAndPositionalArguments() throws Exception {
|
public void testMixedNamedAndPositionalArguments() throws Exception {
|
||||||
doTest("idea/testData/quickfix/checkArguments/beforeMixedNamedAndPositionalArguments.kt");
|
doTest("idea/testData/quickfix/checkArguments/beforeMixedNamedAndPositionalArguments.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user