fix parameter popup for vararg methods (was empty for vararg params)

This commit is contained in:
Dmitry Batrak
2017-10-04 11:25:24 +03:00
parent ad6f438190
commit bb32a6b110
2 changed files with 10 additions and 4 deletions
@@ -1,6 +1,4 @@
// Copyright 2000-2017 JetBrains s.r.o.
// Use of this source code is governed by the Apache 2.0 license that can be
// found in the LICENSE file.
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.hint.api.impls;
import com.intellij.codeInsight.AnnotationTargetUtil;
@@ -563,13 +561,15 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
buffer.append("(");
}
final int currentParameter = context.getCurrentParameterIndex();
int currentParameter = context.getCurrentParameterIndex();
PsiParameter[] parms = method.getParameterList().getParameters();
int numParams = parms.length;
int highlightStartOffset = -1;
int highlightEndOffset = -1;
if (numParams > 0) {
if (context.isSingleParameterInfo() && method.isVarArgs() && currentParameter >= numParams) currentParameter = numParams - 1;
for (int j = 0; j < numParams; j++) {
if (context.isSingleParameterInfo() && j != currentParameter) continue;
@@ -364,20 +364,26 @@ public class CompletionHintsTest extends LightFixtureCompletionTestCase {
public void testVarargWithNoMandatoryArguments() throws Exception {
configureJava("class C { int vararg(int... args){ return 0; } void m() { varar<caret> } }");
complete();
waitForAllAsyncStuff();
checkResultWithInlays("class C { int vararg(int... args){ return 0; } void m() { vararg(<HINT text=\"args:\"/><caret>) } }");
checkHintContents("<html><b>int...</b></html>");
type("1");
next();
waitForAllAsyncStuff();
checkResultWithInlays("class C { int vararg(int... args){ return 0; } void m() { vararg(<hint text=\"args:\"/>1, <caret>) } }");
checkHintContents("<html><b>int...</b></html>");
next();
waitForAllAsyncStuff();
checkResultWithInlays("class C { int vararg(int... args){ return 0; } void m() { vararg(<hint text=\"args:\"/>1)<caret> } }");
checkHintContents(null);
prev();
waitForAllAsyncStuff();
checkResultWithInlays("class C { int vararg(int... args){ return 0; } void m() { vararg(<hint text=\"args:\"/>1, <caret>) } }");
checkHintContents("<html><b>int...</b></html>");
prev();
waitForAllAsyncStuff();
checkResultWithInlays("class C { int vararg(int... args){ return 0; } void m() { vararg(<HINT text=\"args:\"/>1<caret>) } }");
checkHintContents("<html><b>int...</b></html>");
}
public void testVarargWithTwoMandatoryArguments() throws Exception {