mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
IDEA-175672 Duplicate "new char[]" suggestions
This commit is contained in:
@@ -308,12 +308,24 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
|
||||
if (JavaSmartCompletionContributor.AFTER_NEW.accepts(position)) {
|
||||
session.flushBatchItems();
|
||||
new JavaInheritorsGetter(ConstructorInsertHandler.BASIC_INSTANCE).generateVariants(parameters, matcher, session::addClassItem);
|
||||
new JavaInheritorsGetter(ConstructorInsertHandler.BASIC_INSTANCE).generateVariants(parameters, matcher, lookupElement -> {
|
||||
if (!isSuggestedByKeywordCompletion(lookupElement)) {
|
||||
session.addClassItem(lookupElement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
suggestSmartCast(parameters, session, false, result);
|
||||
}
|
||||
|
||||
private static boolean isSuggestedByKeywordCompletion(LookupElement lookupElement) {
|
||||
if (lookupElement instanceof PsiTypeLookupItem) {
|
||||
PsiType type = ((PsiTypeLookupItem)lookupElement).getType();
|
||||
return type instanceof PsiArrayType && ((PsiArrayType)type).getComponentType() instanceof PsiPrimitiveType;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void suggestSmartCast(CompletionParameters parameters, JavaCompletionSession session, boolean quick, Consumer<LookupElement> result) {
|
||||
if (SmartCastProvider.shouldSuggestCast(parameters)) {
|
||||
session.flushBatchItems();
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
{
|
||||
char[] cc = new cha<caret>x
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
public class Bar {
|
||||
{
|
||||
int[] a = new in<caret>
|
||||
int[] a = new in<caret>x
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
public class Bar {
|
||||
{
|
||||
int[] a = new int[<caret>]
|
||||
int[] a = new int[<caret>]x
|
||||
}
|
||||
}
|
||||
@@ -683,6 +683,11 @@ public class ListUtils {
|
||||
assert myFixture.lookupElementStrings == ['void']
|
||||
}
|
||||
|
||||
void testNoExpectedArrayTypeDuplication() {
|
||||
configure()
|
||||
assert myFixture.lookupElementStrings == ['char']
|
||||
}
|
||||
|
||||
void testMethodReturnType() throws Throwable {
|
||||
doTest()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user