Search in sources :

Example 1 with SearchTopHitProvider

use of com.intellij.ide.SearchTopHitProvider in project intellij-community by JetBrains.

the class GotoActionItemProvider method processTopHits.

private static boolean processTopHits(String pattern, Processor<MatchedValue> consumer, DataContext dataContext) {
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final CollectConsumer<Object> collector = new CollectConsumer<>();
    for (SearchTopHitProvider provider : SearchTopHitProvider.EP_NAME.getExtensions()) {
        if (provider instanceof OptionsTopHitProvider.CoveredByToggleActions)
            continue;
        if (provider instanceof OptionsTopHitProvider && !((OptionsTopHitProvider) provider).isEnabled(project))
            continue;
        if (provider instanceof OptionsTopHitProvider && !StringUtil.startsWith(pattern, "#")) {
            String prefix = "#" + ((OptionsTopHitProvider) provider).getId() + " ";
            provider.consumeTopHits(prefix + pattern, collector, project);
        }
        provider.consumeTopHits(pattern, collector, project);
    }
    Collection<Object> result = collector.getResult();
    return processItems(pattern, JBIterable.from(result).filter(Comparable.class), consumer);
}
Also used : Project(com.intellij.openapi.project.Project) CollectConsumer(com.intellij.util.CollectConsumer) OptionsTopHitProvider(com.intellij.ide.ui.OptionsTopHitProvider) SearchTopHitProvider(com.intellij.ide.SearchTopHitProvider)

Aggregations

SearchTopHitProvider (com.intellij.ide.SearchTopHitProvider)1 OptionsTopHitProvider (com.intellij.ide.ui.OptionsTopHitProvider)1 Project (com.intellij.openapi.project.Project)1 CollectConsumer (com.intellij.util.CollectConsumer)1