show params info: ignore varargs conflicts, current index calculation

This commit is contained in:
Anna Kozlova
2014-12-01 18:00:33 +01:00
parent f344994a37
commit 08a7e5b8bf
5 changed files with 26 additions and 7 deletions
@@ -56,4 +56,9 @@ public class CompletionParameterTypeInferencePolicy extends ProcessCandidatePara
}
return guess;
}
@Override
public boolean isVarargsIgnored() {
return true;
}
}
@@ -35,11 +35,7 @@ public abstract class ParameterTypeInferencePolicy {
public abstract PsiType adjustInferredType(PsiManager manager, PsiType guess, ConstraintType second);
/**
* @return true when Object bounds would be rejected in the hope that outer call could provide more information. Should be used for java 1.8 only
*/
@Deprecated
public boolean allowPostponeInference() {
public boolean isVarargsIgnored() {
return false;
}
}
@@ -273,7 +273,7 @@ public class MethodCandidateInfo extends CandidateInfo{
}
final PsiMethod method = getElement();
final CurrentCandidateProperties alreadyThere =
map.put(getMarkerList(), new CurrentCandidateProperties(method, super.getSubstitutor(), isVarargs(), !includeReturnConstraint));
map.put(getMarkerList(), new CurrentCandidateProperties(method, super.getSubstitutor(), policy.isVarargsIgnored() || isVarargs(), !includeReturnConstraint));
try {
PsiTypeParameter[] typeParameters = method.getTypeParameters();
@@ -0,0 +1,9 @@
class Test {
{
final String method = getParentOfType(String.class, CharSe<caret>quence.class);
}
public static <T extends CharSequence> T getParentOfType(Class<T> aClass, Class<? extends CharSequence>... stopAt) {
return null;
}
}
@@ -144,7 +144,15 @@ public class ParameterInfoTest extends LightCodeInsightTestCase {
doTestPresentation("<html>List&lt;String&gt; param</html>");
}
public void testIgnoreVarargs() throws Exception {
doTestPresentation("<html>Class&lt;CharSequence&gt; aClass, <b>Class&lt;? extends CharSequence&gt;... stopAt</b></html>", 1);
}
private void doTestPresentation(String expectedString) {
doTestPresentation(expectedString, -1);
}
private void doTestPresentation(String expectedString, int currentParameterIndex) {
configureByFile(BASE_PATH + getTestName(false) + ".java");
final MethodParameterInfoHandler handler = new MethodParameterInfoHandler();
@@ -156,7 +164,8 @@ public class ParameterInfoTest extends LightCodeInsightTestCase {
assertEquals(1, itemsToShow.length);
assertTrue(itemsToShow[0] instanceof MethodCandidateInfo);
final PsiMethod method = ((MethodCandidateInfo)itemsToShow[0]).getElement();
final ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, myEditor, handler, -1);
final ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, myEditor, handler,
currentParameterIndex);
Assert.assertEquals(expectedString,
MethodParameterInfoHandler
.updateMethodPresentation(method, ((MethodCandidateInfo)itemsToShow[0]).getSubstitutor(), parameterContext));