@Override
  @Nullable
  public Project guessProjectForFile(@Nullable("for plugin compatibility only; actually it should have been notnull") VirtualFile file) {
    if (file == null) {
      return null;
    }

    // StubUpdatingIndex calls this method very often, so, optimized implementation is required
    Project project = ProjectCoreUtil.theOnlyOpenProject();
    if (project != null && !project.isDisposed()) {
      return project;
    }

    project = getPreferredProject(file);
    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 ReadAction.compute(() -> {
      for (Project openProject : projectManager.getOpenProjects()) {
        if (isUnder(openProject, file)) {
          return openProject;
        }
      }
      return null;
    });
  }
@Override
  @Nullable
  public Project guessProjectForFile(@Nullable("for plugin compatibility only; actually it should have been notnull") VirtualFile file)