private static @Nullable VirtualFile getVirtualFile(@NotNull Document document) {
    VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
    if (virtualFile == null || !virtualFile.isValid()) return null;
    return virtualFile;
  }
private static @Nullable VirtualFile getVirtualFile(@NotNull Document document)