Search in sources :

Example 1 with LiveTemplateLookupElement

use of com.intellij.codeInsight.template.impl.LiveTemplateLookupElement in project intellij-community by JetBrains.

the class CompletionLookupArranger method getExactMatches.

private List<LookupElement> getExactMatches(LookupImpl lookup, List<LookupElement> items) {
    String selectedText = lookup.getTopLevelEditor().getSelectionModel().getSelectedText();
    List<LookupElement> exactMatches = new SmartList<>();
    for (int i = 0; i < items.size(); i++) {
        LookupElement item = items.get(i);
        boolean isSuddenLiveTemplate = isSuddenLiveTemplate(item);
        if (isPrefixItem(item, true) && !isSuddenLiveTemplate || item.getLookupString().equals(selectedText)) {
            if (item instanceof LiveTemplateLookupElement) {
                // prefer most recent live template lookup item
                return Collections.singletonList(item);
            }
            exactMatches.add(item);
        } else if (i == 0 && isSuddenLiveTemplate && items.size() > 1 && !CompletionServiceImpl.isStartMatch(items.get(1), this)) {
            return Collections.singletonList(item);
        }
    }
    return exactMatches;
}
Also used : LiveTemplateLookupElement(com.intellij.codeInsight.template.impl.LiveTemplateLookupElement) SmartList(com.intellij.util.SmartList) LiveTemplateLookupElement(com.intellij.codeInsight.template.impl.LiveTemplateLookupElement)

Aggregations

LiveTemplateLookupElement (com.intellij.codeInsight.template.impl.LiveTemplateLookupElement)1 SmartList (com.intellij.util.SmartList)1