private static @Nullable VirtualFile getVirtualFile(@NotNull PsiFile psiFile, @Nullable Document document) {
    VirtualFile file = psiFile.getVirtualFile();
    if (file != null) {
      return file;
    }
    if (document != null) {
      return FileDocumentManager.getInstance().getFile(document);
    }
    return null;
  }
private static @Nullable VirtualFile getVirtualFile(@NotNull PsiFile psiFile, @Nullable Document document)