private static boolean processFile(@NotNull List<? extends SamDescriptor> descriptors,
                                     @NotNull VirtualFile vFile,
                                     @NotNull Map<FunExprOccurrence, Confidence> occurrences,
                                     @NotNull Session session) {
    return descriptors.get(0).dumbService.runReadActionInSmartMode(() -> {
      PsiManager manager = descriptors.get(0).samClass.getManager();
      PsiFile file = manager.findFile(vFile);
      if (!(file instanceof PsiJavaFile)) {
        LOG.error("Non-java file " + file + "; " + vFile);
        return true;
      }

      Map<TextRange, PsiFile> fragmentCache = new HashMap<>();

      @NotNull List<JavaFunctionalExpressionIndex.IndexEntry> data = ContainerUtil.flatten(
        FileBasedIndex.getInstance().getFileData(JavaFunctionalExpressionIndex.INDEX_ID, vFile, manager.getProject()).values());
      for (JavaFunctionalExpressionIndex.IndexEntry entry : data) {
        Confidence confidence = occurrences.get(entry.occurrence);
        if (confidence != null) {
          (confidence == Confidence.sure ? session.sureExprsAfterLightCheck : session.exprsToHeavyCheck).incrementAndGet();

          int offset = entry.exprStart;
          boolean useAST = ((PsiFileEx)file).isContentsLoaded();
          PsiFunctionalExpression expression = useAST ? findPsiByAST(file, offset) : findPsiByStubs(file, entry.exprIndex);
          if (expression == null) {
            LOG.error("Fun expression not found in " + file + " at " + offset);
            continue;
          }

          if (confidence == Confidence.needsCheck) {
            PsiFunctionalExpression toCheck = useAST ? expression : getNonPhysicalCopy(fragmentCache, entry, expression);
            if (!hasType(descriptors, toCheck)) {
              continue;
            }
          }

          if (!session.consumer.process(expression)) {
            return false;
          }
        }
      }
      return true;
    });
  }
private static boolean processFile(@NotNull List<? extends SamDescriptor> descriptors,
                                     @NotNull VirtualFile vFile,
                                     @NotNull Map<FunExprOccurrence, Confidence> occurrences,
                                     @NotNull Session session)