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();
}
});
}
Aggregations