mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
show param info: highlight overload vararg method
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String> 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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user