boolean (@NotNull List<? extends VirtualFile> files, int totalSize, int alreadyProcessedFiles, @NotNull ProgressIndicator progress, @NotNull Processor<? super PsiFile> localProcessor) { return myManager.runInBatchFilesMode(() -> { AtomicInteger counter = new AtomicInteger(alreadyProcessedFiles); AtomicBoolean stopped = new AtomicBoolean(false); if (progress.isRunning()) { progress.setIndeterminate(false); } ProgressIndicator originalIndicator = ProgressWrapper.unwrapAll(progress); return processFilesConcurrentlyDespiteWriteActions(myManager.getProject(), files, progress, stopped, vfile -> { TooManyUsagesStatus.getFrom(originalIndicator).pauseProcessingIfTooManyUsages(); try { processVirtualFile(vfile, stopped, localProcessor); } catch (ProcessCanceledException | IndexNotReadyException e) { throw e; } catch (Throwable e) { LOG.error("Error during processing of: " + vfile.getName(), e); throw e; } if (progress.isRunning() && !progress.isIndeterminate()) { double fraction = (double)counter.incrementAndGet() / totalSize; progress.setFraction(fraction); } return !stopped.get(); }); }); }