public static @Nullable Document getDocumentToBeUsedFor(final PsiFile file) {
    final Project project = file.getProject();
    if (!file.isPhysical()) {
      return getDocumentForNonPhysicalFile(file);
    }
    final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
    if (document != null) {
      if (PsiDocumentManager.getInstance(project).isUncommited(document)) return null;
      PsiToDocumentSynchronizer synchronizer = ((PsiDocumentManagerBase)PsiDocumentManager.getInstance(project)).getSynchronizer();
      if (synchronizer.isDocumentAffectedByTransactions(document)) return null;
    }
    return document;
  }
public static @Nullable Document getDocumentToBeUsedFor(final PsiFile file)