BulkOccurrenceProcessor (@NotNull PsiSearchRequest singleRequest, @NotNull Processor<? super PsiReference> consumer) { SearchScope searchScope = singleRequest.searchScope; boolean ignoreInjectedPsi = searchScope instanceof LocalSearchScope && ((LocalSearchScope)searchScope).isIgnoreInjectedPsi(); RequestResultProcessor wrapped = singleRequest.processor; return new BulkOccurrenceProcessor() { @Override public boolean execute(@NotNull PsiElement scope, int @NotNull [] offsetsInScope, @NotNull StringSearcher searcher) { ProgressManager.checkCanceled(); if (wrapped instanceof RequestResultProcessor.BulkResultProcessor) { return ((RequestResultProcessor.BulkResultProcessor)wrapped).processTextOccurrences(scope, offsetsInScope, consumer); } return LowLevelSearchUtil.processElementsAtOffsets(scope, searcher, !ignoreInjectedPsi, getOrCreateIndicator(), offsetsInScope, (element, offsetInElement) -> { if (ignoreInjectedPsi && element instanceof PsiLanguageInjectionHost) return true; return wrapped.processTextOccurrence(element, offsetInElement, consumer); }); } @Override public String toString() { return consumer.toString(); } }; }