mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
IDEA-CR-12743, IDEA-157088 The autocomplete to offer not only the implementation of the interface, but the interface itself (when Object arrays are expected)
This commit is contained in:
@@ -84,7 +84,8 @@ public class JavaInheritorsGetter extends CompletionProvider<CompletionParameter
|
||||
addArrayTypes(parameters.getPosition(), infos, consumer);
|
||||
|
||||
List<PsiClassType> classTypes = extractClassTypes(infos);
|
||||
boolean arraysWelcome = classTypes.stream().anyMatch(t -> t.equalsToText(CommonClassNames.JAVA_LANG_OBJECT));
|
||||
boolean arraysWelcome = ContainerUtil.exists(ExpectedTypesGetter.extractTypes(infos, true),
|
||||
t -> t.getDeepComponentType().equalsToText(CommonClassNames.JAVA_LANG_OBJECT));
|
||||
processInheritors(parameters, classTypes, prefixMatcher, type -> {
|
||||
final LookupElement element = addExpectedType(type, parameters);
|
||||
if (element != null) {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
interface MyIntf {}
|
||||
|
||||
void foo(MyIntf i){}
|
||||
void foo(Object[] array){}
|
||||
|
||||
void test() {
|
||||
foo(new MyIntf<caret>)
|
||||
}
|
||||
+6
@@ -1603,4 +1603,10 @@ class Bar {
|
||||
assert LookupElementPresentation.renderElement(myFixture.lookup.items[0]).tailText.contains('{...}')
|
||||
assert LookupElementPresentation.renderElement(myFixture.lookup.items[1]).tailText.contains('[]')
|
||||
}
|
||||
|
||||
public void testSuggestInterfaceArrayWhenObjectArrayIsExpected() {
|
||||
configure()
|
||||
assert LookupElementPresentation.renderElement(myFixture.lookup.items[0]).tailText.contains('{...}')
|
||||
assert LookupElementPresentation.renderElement(myFixture.lookup.items[1]).tailText.contains('[]')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user