mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
fix parameter info after generics (IDEA-114245)
This commit is contained in:
@@ -387,7 +387,7 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
|
||||
for (int j = 0; j < numParams; j++) {
|
||||
PsiParameter param = parms[j];
|
||||
|
||||
int startOffset = buffer.length();
|
||||
int startOffset = XmlStringUtil.escapeString(buffer.toString()).length();
|
||||
|
||||
if (param.isValid()) {
|
||||
PsiType paramType = param.getType();
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.util.*;
|
||||
|
||||
class First {
|
||||
public static <T> List<T> first(final Class<T> type, boolean tags) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> List<T> first(final Class<T> type) {
|
||||
return first(type, <caret>true);
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,25 @@ public class ParameterInfoTest extends LightCodeInsightTestCase {
|
||||
doTestPresentation("<html>List<String> param</html>");
|
||||
}
|
||||
|
||||
public void testAfterGenericsInsideCall() 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 PsiMethod method = ((MethodCandidateInfo)itemsToShow[0]).getElement();
|
||||
final ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, myEditor, handler, 1);
|
||||
parameterContext.setUIComponentEnabled(true);
|
||||
Assert.assertEquals("<html>Class<T> type, <b>boolean tags</b></html>",
|
||||
MethodParameterInfoHandler
|
||||
.updateMethodPresentation(method, ((MethodCandidateInfo)itemsToShow[0]).getSubstitutor(), parameterContext));
|
||||
}
|
||||
|
||||
public void testGenericsOutsideCall() throws Exception {
|
||||
doTestPresentation("<html>List<String> param</html>");
|
||||
}
|
||||
@@ -70,7 +89,7 @@ public class ParameterInfoTest extends LightCodeInsightTestCase {
|
||||
assertTrue(itemsToShow.length == 1);
|
||||
assertTrue(itemsToShow[0] instanceof MethodCandidateInfo);
|
||||
final PsiMethod method = ((MethodCandidateInfo)itemsToShow[0]).getElement();
|
||||
final ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, myEditor, handler);
|
||||
final ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, myEditor, handler, -1);
|
||||
Assert.assertEquals(expectedString,
|
||||
MethodParameterInfoHandler
|
||||
.updateMethodPresentation(method, ((MethodCandidateInfo)itemsToShow[0]).getSubstitutor(), parameterContext));
|
||||
@@ -92,7 +111,7 @@ public class ParameterInfoTest extends LightCodeInsightTestCase {
|
||||
assertTrue(itemsToShow.length == 1);
|
||||
assertTrue(itemsToShow[0] instanceof PsiAnnotationMethod);
|
||||
final PsiAnnotationMethod method = (PsiAnnotationMethod)itemsToShow[0];
|
||||
final ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, myEditor, handler);
|
||||
final ParameterInfoUIContextEx parameterContext = ParameterInfoComponent.createContext(itemsToShow, myEditor, handler, -1);
|
||||
Assert.assertEquals(expectedString,
|
||||
AnnotationParameterInfoHandler.updateUIText(method, parameterContext));
|
||||
}
|
||||
|
||||
@@ -75,8 +75,10 @@ public class ParameterInfoComponent extends JPanel {
|
||||
};
|
||||
|
||||
@TestOnly
|
||||
public static ParameterInfoUIContextEx createContext(Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler) {
|
||||
return new ParameterInfoComponent(objects, editor, handler).new MyParameterContext();
|
||||
public static ParameterInfoUIContextEx createContext(Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler, int currentParameterIndex) {
|
||||
final ParameterInfoComponent infoComponent = new ParameterInfoComponent(objects, editor, handler);
|
||||
infoComponent.setCurrentParameterIndex(currentParameterIndex);
|
||||
return infoComponent.new MyParameterContext();
|
||||
}
|
||||
|
||||
ParameterInfoComponent(Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler) {
|
||||
|
||||
Reference in New Issue
Block a user