show param info: highlight overload vararg method

This commit is contained in:
Anna Kozlova
2013-12-12 20:05:37 +04:00
parent 8db186e18a
commit 6f5e28c4d0
3 changed files with 51 additions and 2 deletions

View File

@@ -228,10 +228,15 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
PsiExpression arg = args[j];
assert parm.isValid();
assert arg.isValid();
PsiType parmType = substitutor.substitute(parm.getType());
PsiType parmType = parm.getType();
PsiType argType = arg.getType();
if (argType == null) continue;
if (parmType instanceof PsiEllipsisType && parmType.getArrayDimensions() == argType.getArrayDimensions() + 1) {
parmType = ((PsiEllipsisType)parmType).getComponentType();
}
parmType = substitutor.substitute(parmType);
if (argType != null && !parmType.isAssignableFrom(argType)) {
if (!parmType.isAssignableFrom(argType)) {
return false;
}
}

View File

@@ -0,0 +1,12 @@
class Test {
{
refresh(<caret>false, false, null, "");
}
public final void refresh(boolean async, boolean recursive, Runnable finishRunnable, String... files) {
}
public final void refresh(boolean async, boolean recursive, Runnable finishRunnable, Integer files) {
}
}

View File

@@ -10,6 +10,9 @@ import com.intellij.psi.*;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.testFramework.utils.parameterInfo.MockCreateParameterInfoContext;
import com.intellij.testFramework.utils.parameterInfo.MockUpdateParameterInfoContext;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.Function;
import junit.framework.Assert;
@@ -54,6 +57,35 @@ public class ParameterInfoTest extends LightCodeInsightTestCase {
doTestPresentation("<html>List&lt;String&gt; param</html>");
}
public void testSelectionWithGenerics() throws Exception {
configureByFile(BASE_PATH + getTestName(false) + ".java");
final MethodParameterInfoHandler handler = new MethodParameterInfoHandler();
final CreateParameterInfoContext context = new MockCreateParameterInfoContext(myEditor, myFile);
final PsiExpressionList list = handler.findElementForParameterInfo(context);
assertNotNull(list);
final Object[] itemsToShow = context.getItemsToShow();
assertNotNull(itemsToShow);
assertTrue(itemsToShow.length == 2);
assertTrue(itemsToShow[0] instanceof MethodCandidateInfo);
final ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, myEditor, handler, -1);
final Boolean [] enabled = new Boolean[itemsToShow.length];
final MockUpdateParameterInfoContext updateParameterInfoContext = new MockUpdateParameterInfoContext(myEditor, myFile){
@Override
public Object[] getObjectsToView() {
return itemsToShow;
}
@Override
public void setUIComponentEnabled(int index, boolean b) {
enabled[index] = b;
}
};
updateParameterInfoContext.setParameterOwner(list);
handler.updateParameterInfo(list, updateParameterInfoContext);
assertTrue(ArrayUtilRt.find(enabled, Boolean.TRUE) > -1);
}
public void testAfterGenericsInsideCall() throws Exception {
configureByFile(BASE_PATH + getTestName(false) + ".java");