use of com.intellij.util.Processors in project intellij-community by JetBrains.
the class PsiSearchHelperImpl method collectFiles.
private void collectFiles(@NotNull MultiMap<Set<IdIndexEntry>, RequestWithProcessor> singles, @NotNull ProgressIndicator progress, @NotNull final MultiMap<VirtualFile, RequestWithProcessor> intersectionResult, @NotNull final MultiMap<VirtualFile, RequestWithProcessor> restResult) {
for (Map.Entry<Set<IdIndexEntry>, Collection<RequestWithProcessor>> entry : singles.entrySet()) {
final Set<IdIndexEntry> keys = entry.getKey();
if (keys.isEmpty()) {
continue;
}
final Collection<RequestWithProcessor> processors = entry.getValue();
final GlobalSearchScope commonScope = uniteScopes(processors);
final Set<VirtualFile> intersectionWithContainerNameFiles = intersectionWithContainerNameFiles(commonScope, processors, keys);
List<VirtualFile> result = new ArrayList<>();
Processor<VirtualFile> processor = Processors.cancelableCollectProcessor(result);
processFilesContainingAllKeys(myManager.getProject(), commonScope, null, keys, processor);
for (final VirtualFile file : result) {
progress.checkCanceled();
for (final IdIndexEntry indexEntry : keys) {
DumbService.getInstance(myManager.getProject()).runReadActionInSmartMode(() -> FileBasedIndex.getInstance().processValues(IdIndex.NAME, indexEntry, file, (file1, value) -> {
int mask = value.intValue();
for (RequestWithProcessor single : processors) {
final PsiSearchRequest request = single.request;
if ((mask & request.searchContext) != 0 && request.searchScope.contains(file1)) {
MultiMap<VirtualFile, RequestWithProcessor> result1 = intersectionWithContainerNameFiles == null || !intersectionWithContainerNameFiles.contains(file1) ? restResult : intersectionResult;
result1.putValue(file1, single);
}
}
return true;
}, commonScope));
}
}
}
}
Aggregations