Search in sources :

Example 1 with MatcherHolder

use of com.intellij.util.text.MatcherHolder in project intellij-community by JetBrains.

the class ChooseByNameBase method rebuildList.

protected void rebuildList(final int pos, final int delay, @NotNull final ModalityState modalityState, @Nullable final Runnable postRunnable) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    if (!myInitialized) {
        return;
    }
    myAlarm.cancelAllRequests();
    if (delay > 0) {
        myAlarm.addRequest(() -> rebuildList(pos, 0, modalityState, postRunnable), delay, ModalityState.stateForComponent(myTextField));
        return;
    }
    myListUpdater.cancelAll();
    final CalcElementsThread calcElementsThread = myCalcElementsThread;
    if (calcElementsThread != null) {
        calcElementsThread.cancel();
    }
    final String text = getTrimmedText();
    if (!canShowListForEmptyPattern() && text.isEmpty()) {
        myListModel.removeAll();
        hideList();
        myTextFieldPanel.hideHint();
        myCard.show(myCardContainer, CHECK_BOX_CARD);
        return;
    }
    ListCellRenderer cellRenderer = myList.getCellRenderer();
    if (cellRenderer instanceof ExpandedItemListCellRendererWrapper) {
        cellRenderer = ((ExpandedItemListCellRendererWrapper) cellRenderer).getWrappee();
    }
    final String pattern = patternToLowerCase(transformPattern(text));
    final Matcher matcher = buildPatternMatcher(isSearchInAnyPlace() ? "*" + pattern : pattern);
    if (cellRenderer instanceof MatcherHolder) {
        ((MatcherHolder) cellRenderer).setPatternMatcher(matcher);
    }
    MatcherHolder.associateMatcher(myList, matcher);
    scheduleCalcElements(text, myCheckBox.isSelected(), modalityState, elements -> {
        ApplicationManager.getApplication().assertIsDispatchThread();
        backgroundCalculationFinished(elements, pos);
        if (postRunnable != null) {
            postRunnable.run();
        }
    });
}
Also used : Matcher(com.intellij.util.text.Matcher) MinusculeMatcher(com.intellij.psi.codeStyle.MinusculeMatcher) MatcherHolder(com.intellij.util.text.MatcherHolder)

Aggregations

MinusculeMatcher (com.intellij.psi.codeStyle.MinusculeMatcher)1 Matcher (com.intellij.util.text.Matcher)1 MatcherHolder (com.intellij.util.text.MatcherHolder)1