private boolean worthBothering(@Nullable Document document, @Nullable Project guessedProject) {
    if (document == null) {
      return true;
    }
    if (guessedProject != null && guessedProject != myProject) {
      return false;
    }
    if (myProject.isDisposed()) {
      return false;
    }
    // Used to be these lines:

    /*
    // cached is essential here since we do not want to create PSI file in alien project
    PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getCachedPsiFile(document);
    return psiFile != null && psiFile.isPhysical() && psiFile.getOriginalFile() == psiFile;
    */

    // But had to replace them with the heuristics below which are not PSI-related to avoid accessing indexes in EDT
    // see EA-659452 T: DirectoryIndexImpl.getInfoForFile
    // and please don't do anything PSIthic here
    VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
    if (virtualFile == null || virtualFile instanceof LightVirtualFile) {
      return false;
    }
    // non-physical docs can be updated outside EDT as a rule
    return !(document instanceof DocumentImpl impl) || impl.isWriteThreadOnly();
  }
private boolean worthBothering(@Nullable Document document, @Nullable Project guessedProject)