mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
no duplicates in java var name suggestions
This commit is contained in:
+7
@@ -361,11 +361,18 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
private static void addLookupItems(Set<LookupElement> lookupElements, @Nullable final SuggestedNameInfo callback, PrefixMatcher matcher, String... strings) {
|
||||
outer:
|
||||
for (int i = 0; i < strings.length; i++) {
|
||||
String name = strings[i];
|
||||
if (!matcher.prefixMatches(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (LookupElement lookupElement : lookupElements) {
|
||||
if (lookupElement.getAllLookupStrings().contains(name)) {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
LookupElement element = PrioritizedLookupElement.withPriority(LookupElementBuilder.create(name).withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE), -i);
|
||||
if (callback != null) {
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
public class Foo {
|
||||
|
||||
void bar() {
|
||||
APreferencePolicy p<caret> = 2;
|
||||
System.out.println(policy);
|
||||
}
|
||||
}
|
||||
|
||||
class APreferencePolicy {
|
||||
|
||||
}
|
||||
+5
@@ -157,4 +157,9 @@ public class VariablesCompletionTest extends LightFixtureCompletionTestCase {
|
||||
assertStringItems("stringBuffer", "buffer");
|
||||
}
|
||||
|
||||
public void testDuplicateSuggestionsFromUsage() {
|
||||
configureByFile(FILE_PREFIX + getTestName(false) + ".java");
|
||||
assertStringItems("preferencePolicy", "policy");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user