[java] IDEA-255890 'Complete Current Statement' for vararg method like String.format works incorrectly

GitOrigin-RevId: 814641fd0562890897eec6e0a7f29c187f36c54c
This commit is contained in:
Tagir Valeev
2020-12-04 08:06:35 +00:00
committed by intellij-monorepo-bot
parent 84c09cc922
commit 2a18b3e8f9
4 changed files with 14 additions and 1 deletions
@@ -93,7 +93,7 @@ public class MethodCallFixer implements Fixer {
int paramCount = Integer.MAX_VALUE;
for (CandidateInfo candidate : PsiResolveHelper.SERVICE.getInstance(call.getProject()).getReferencedMethodCandidates(call, false)) {
PsiElement element = candidate.getElement();
if (element instanceof PsiMethod) {
if (element instanceof PsiMethod && !((PsiMethod)element).isVarArgs()) {
paramCount = Math.min(paramCount, ((PsiMethod)element).getParameterList().getParametersCount());
}
}
@@ -0,0 +1,6 @@
public class VarargMethod {
void test() {
List<String> list = new ArrayList<>();
list.add(String.format("m", p1, p2)<caret>
}
}
@@ -0,0 +1,6 @@
public class VarargMethod {
void test() {
List<String> list = new ArrayList<>();
list.add(String.format("m", p1, p2));
}
}
@@ -181,6 +181,7 @@ public class CompleteStatementTest extends EditorActionTestCase {
public void testRecord() { doTest(); }
public void testRecordWithComponent() { doTest(); }
public void testRecordWithComponentNoBody() { doTest(); }
public void testVarargMethod() { doTest(); }
private void doTestBracesNextLineStyle() {
myJavaSettings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;