private static @Nullable Project guessProject(@Nullable VirtualFile virtualFile) {
    Project project = virtualFile == null ? null : ProjectLocator.getInstance().guessProjectForFile(virtualFile);
    if (project != null) {
      return project;
    }
    ProjectManager projectManager = ProjectManager.getInstanceIfCreated();
    if (projectManager == null) {
      return null;
    }

    Project[] openProjects = projectManager.getOpenProjects();
    if (openProjects.length == 1) {
      return openProjects[0];
    }
    return null;
  }
private static @Nullable Project guessProject(@Nullable VirtualFile virtualFile)