com.intellij.codeInsight.completion.CompletionSorter Java Examples
The following examples show how to use
com.intellij.codeInsight.completion.CompletionSorter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleCompletionExtension.java From camel-idea-plugin with Apache License 2.0 | 6 votes |
@Override public void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet resultSet, @NotNull String[] query) { PsiElement element = parameters.getPosition(); Module module = ModuleUtilCore.findModuleForPsiElement(element); if (module == null) { return; } List<LookupElement> results = findResults(element, getQueryAtPosition(query)); if (!results.isEmpty()) { resultSet .withRelevanceSorter(CompletionSorter.emptySorter()) .addAllElements(results); resultSet.stopHere(); } }
Example #2
Source File: CSharpCompletionSorting.java From consulo-csharp with Apache License 2.0 | 5 votes |
@RequiredReadAction public static CompletionResultSet modifyResultSet(CompletionParameters completionParameters, CompletionResultSet result) { CompletionSorter sorter = CompletionSorter.defaultSorter(completionParameters, result.getPrefixMatcher()); List<LookupElementWeigher> afterStats = new ArrayList<>(); afterStats.add(new KindSorter()); ContainerUtil.addIfNotNull(afterStats, recursiveSorter(completionParameters, result)); List<LookupElementWeigher> afterProximity = new ArrayList<>(); List<ExpectedTypeInfo> expectedTypeRefs = ExpectedTypeVisitor.findExpectedTypeRefs(completionParameters.getPosition()); if(expectedTypeRefs.isEmpty()) { expectedTypeRefs = ExpectedTypeVisitor.findExpectedTypeRefs(completionParameters.getPosition().getParent()); } if(!expectedTypeRefs.isEmpty()) { afterProximity.add(new ExpectedNameSorter(expectedTypeRefs)); afterProximity.add(new PreferShorter(expectedTypeRefs)); } afterProximity.add(new NotImportedSorter()); sorter = sorter.weighAfter("stats", afterStats.toArray(new LookupElementWeigher[afterStats.size()])); sorter = sorter.weighAfter("proximity", afterProximity.toArray(new LookupElementWeigher[afterProximity.size()])); result = result.withRelevanceSorter(sorter); return result; }
Example #3
Source File: ReplacingConsumerTest.java From litho with Apache License 2.0 | 4 votes |
private static CompletionResult createCompletionResultFor(PsiClass cls) { TestLookupElement lookupElement = new TestLookupElement(cls); PrefixMatcher matcher = Mockito.mock(PrefixMatcher.class); Mockito.when(matcher.prefixMatches(any(LookupElement.class))).thenReturn(true); return CompletionResult.wrap(lookupElement, matcher, Mockito.mock(CompletionSorter.class)); }
Example #4
Source File: ReplacingConsumerTest.java From litho with Apache License 2.0 | 4 votes |
@Override public CompletionResultSet withRelevanceSorter(CompletionSorter sorter) { return null; }