Search in sources :

Example 1 with AutoCompletionPolicy

use of com.intellij.codeInsight.lookup.AutoCompletionPolicy in project intellij-community by JetBrains.

the class TextFieldWithAutoCompletionListProvider method addCompletionElements.

private static <T> void addCompletionElements(final CompletionResultSet result, final TextCompletionValueDescriptor<T> descriptor, final Collection<T> items, final int index) {
    final AutoCompletionPolicy completionPolicy = ApplicationManager.getApplication().isUnitTestMode() ? AutoCompletionPolicy.ALWAYS_AUTOCOMPLETE : AutoCompletionPolicy.NEVER_AUTOCOMPLETE;
    int grouping = index;
    for (final T item : items) {
        if (item == null) {
            LOG.error("Null item from " + descriptor);
            continue;
        }
        LookupElementBuilder builder = descriptor.createLookupBuilder(item);
        result.addElement(PrioritizedLookupElement.withGrouping(builder.withAutoCompletionPolicy(completionPolicy), grouping--));
    }
}
Also used : LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder) AutoCompletionPolicy(com.intellij.codeInsight.lookup.AutoCompletionPolicy)

Aggregations

AutoCompletionPolicy (com.intellij.codeInsight.lookup.AutoCompletionPolicy)1 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1