Processor<PsiElement> (@NotNull StringSearcher searcher, @NotNull BulkOccurrenceProcessor processor) { return new ReadActionProcessor<>() { @Override public boolean processInReadAction(PsiElement scopeElement) { if (scopeElement instanceof PsiCompiledElement) { // can't scan text of the element return true; } return scopeElement.isValid() && processor.execute(scopeElement, LowLevelSearchUtil.getTextOccurrencesInScope(scopeElement, searcher), searcher); } @Override public String toString() { return processor.toString(); } }; }