private void processVirtualFile(@NotNull VirtualFile vfile,
                                  @NotNull AtomicBoolean stopped,
                                  @NotNull Processor<CandidateFileInfo> localProcessor) throws ApplicationUtil.CannotRunReadActionException {
    // try to pre-cache virtual file content outside read action to avoid stalling EDT
    if (!vfile.isDirectory() && !vfile.getFileType().isBinary()) {
      try {
        vfile.contentsToByteArray();
      }
      catch (IOException ignored) {
      }
    }
    if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(() -> {
      PsiFile file = vfile.isValid() ? myManager.findFile(vfile) : null;

      //noinspection deprecation
      if (file != null && file.getViewProvider() instanceof BackFileViewProvider) {
        //noinspection deprecation
        file = ((BackFileViewProvider)file.getViewProvider()).getFrontPsiFile();
      }

      if (file instanceof PsiBinaryFile binaryFile) {
        PsiFile originalFile = findOriginalFile(binaryFile);
        if (originalFile != null) {
          file = originalFile;
        }
      }

      if (file != null && !(file instanceof PsiBinaryFile)) {
        Project project = myManager.getProject();
        if (project.isDisposed()) throw new ProcessCanceledException();
        if (!DumbUtil.getInstance(project).mayUseIndices()) {
          throw ApplicationUtil.CannotRunReadActionException.create();
        }

        FileViewProvider provider = file.getViewProvider();
        List<PsiFile> psiRoots = provider.getAllFiles();
        Set<PsiFile> processed = new HashSet<>(psiRoots.size() * 2, (float)0.5);
        for (PsiFile psiRoot : psiRoots) {
          ProgressManager.checkCanceled();
          assert psiRoot != null : "One of the roots of file " + file + " is null. All roots: " + psiRoots + "; ViewProvider: " +
                                   provider + "; Virtual file: " + provider.getVirtualFile();
          if (!processed.add(psiRoot)) continue;
          if (!psiRoot.isValid()) {
            continue;
          }

          if (!localProcessor.process(new CandidateFileInfo(vfile, psiRoot))) {
            stopped.set(true);
            break;
          }
        }
      }
    })) {
      throw ApplicationUtil.CannotRunReadActionException.create();
    }
  }
private void processVirtualFile(@NotNull VirtualFile vfile,
                                  @NotNull AtomicBoolean stopped,
                                  @NotNull Processor<CandidateFileInfo> localProcessor)