mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ensure that everything suggested by class name completion is also suggested on second basic completion invocation (IDEA-86517)
This commit is contained in:
+17
-19
@@ -34,7 +34,6 @@ import com.intellij.psi.filters.types.AssignableFromFilter;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -51,24 +50,23 @@ public class JavaClassNameCompletionContributor extends CompletionContributor {
|
||||
psiElement().afterLeaf(PsiKeyword.EXTENDS, PsiKeyword.SUPER, "&").withParent(
|
||||
psiElement(PsiReferenceList.class).withParent(PsiTypeParameter.class));
|
||||
|
||||
public JavaClassNameCompletionContributor() {
|
||||
extend(CompletionType.CLASS_NAME, psiElement(), new CompletionProvider<CompletionParameters>() {
|
||||
public void addCompletions(@NotNull final CompletionParameters parameters, final ProcessingContext matchingContext, @NotNull final CompletionResultSet _result) {
|
||||
if (shouldShowSecondSmartCompletionHint(parameters) &&
|
||||
CompletionUtil.shouldShowFeature(parameters, CodeCompletionFeatures.SECOND_CLASS_NAME_COMPLETION)) {
|
||||
CompletionService.getCompletionService().setAdvertisementText(CompletionBundle.message("completion.class.name.hint.2", getActionShortcut(IdeActions.ACTION_CLASS_NAME_COMPLETION)));
|
||||
}
|
||||
|
||||
CompletionResultSet result = _result.withPrefixMatcher(CompletionUtil.findReferenceOrAlphanumericPrefix(parameters));
|
||||
addAllClasses(parameters, parameters.getInvocationCount() <= 1,
|
||||
JavaCompletionSorting.addJavaSorting(parameters, result).getPrefixMatcher(), new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
_result.addElement(element);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void fillCompletionVariants(CompletionParameters parameters, final CompletionResultSet _result) {
|
||||
if (parameters.isExtendedCompletion()) {
|
||||
if (shouldShowSecondSmartCompletionHint(parameters) &&
|
||||
CompletionUtil.shouldShowFeature(parameters, CodeCompletionFeatures.SECOND_CLASS_NAME_COMPLETION)) {
|
||||
CompletionService.getCompletionService().setAdvertisementText(CompletionBundle.message("completion.class.name.hint.2", getActionShortcut(IdeActions.ACTION_CODE_COMPLETION)));
|
||||
}
|
||||
});
|
||||
|
||||
CompletionResultSet result = _result.withPrefixMatcher(CompletionUtil.findReferenceOrAlphanumericPrefix(parameters));
|
||||
addAllClasses(parameters, parameters.getInvocationCount() <= 1,
|
||||
JavaCompletionSorting.addJavaSorting(parameters, result).getPrefixMatcher(), new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
_result.addElement(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void addAllClasses(CompletionParameters parameters,
|
||||
@@ -179,7 +177,7 @@ public class JavaClassNameCompletionContributor extends CompletionContributor {
|
||||
return LangBundle.message("completion.no.suggestions") +
|
||||
"; " +
|
||||
StringUtil.decapitalize(
|
||||
CompletionBundle.message("completion.class.name.hint.2", getActionShortcut(IdeActions.ACTION_CLASS_NAME_COMPLETION)));
|
||||
CompletionBundle.message("completion.class.name.hint.2", getActionShortcut(IdeActions.ACTION_CODE_COMPLETION)));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class JavaGlobalMemberNameCompletionContributor extends CompletionContrib
|
||||
|
||||
@Override
|
||||
public void fillCompletionVariants(CompletionParameters parameters, final CompletionResultSet result) {
|
||||
if (parameters.getCompletionType() != CompletionType.CLASS_NAME) {
|
||||
if (!parameters.isExtendedCompletion()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -1,17 +1,17 @@
|
||||
class Foo {
|
||||
int ELEMENT_A = 1;
|
||||
int ELEMENT_B = 1;
|
||||
int ELEMENT_C = 1;
|
||||
int ELEMENT_D = 1;
|
||||
int ELEMENT_E = 1;
|
||||
int ELEMENT_F = 1;
|
||||
int ELEMENT_G = 1;
|
||||
int ELEMENT_H = 1;
|
||||
int ELEMENT_I = 1;
|
||||
int ELXEMENT_A = 1;
|
||||
int ELXEMENT_B = 1;
|
||||
int ELXEMENT_C = 1;
|
||||
int ELXEMENT_D = 1;
|
||||
int ELXEMENT_E = 1;
|
||||
int ELXEMENT_F = 1;
|
||||
int ELXEMENT_G = 1;
|
||||
int ELXEMENT_H = 1;
|
||||
int ELXEMENT_I = 1;
|
||||
|
||||
|
||||
{
|
||||
El<caret>
|
||||
Elx<caret>
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -287,13 +287,13 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
public void testPreselectMostRelevantInTheMiddleAlpha() {
|
||||
UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = true;
|
||||
|
||||
myFixture.addClass("package foo; public class Elaaaaaaaaaaaaaaaaaaaa {}");
|
||||
myFixture.addClass("package foo; public class Elxaaaaaaaaaaaaaaaaaaaa {}");
|
||||
invokeCompletion(getTestName(false) + ".java");
|
||||
myFixture.completeBasic();
|
||||
LookupImpl lookup = getLookup();
|
||||
assertPreferredItems(lookup.getList().getSelectedIndex());
|
||||
assertEquals("Elaaaaaaaaaaaaaaaaaaaa", lookup.getItems().get(0).getLookupString());
|
||||
assertEquals("ELEMENT_A", lookup.getCurrentItem().getLookupString());
|
||||
assertEquals("Elxaaaaaaaaaaaaaaaaaaaa", lookup.getItems().get(0).getLookupString());
|
||||
assertEquals("ELXEMENT_A", lookup.getCurrentItem().getLookupString());
|
||||
}
|
||||
|
||||
public void testReallyAlphaSorting() {
|
||||
|
||||
Reference in New Issue
Block a user