private static String pathToSelect(FileChooserDescriptor descriptor, @Nullable Project project, @Nullable VirtualFile toSelect) {
    String last = getLastOpenedFilePath(project);
    if (last != null && (toSelect == null || descriptor.getUserData(PathChooserDialog.PREFER_LAST_OVER_EXPLICIT) == Boolean.TRUE)) {
      return last;
    }

    if (toSelect != null) {
      return toSelect.getPath();
    }

    if (project != null && !project.isDefault()) {
      VirtualFile projectDir = ProjectUtil.guessProjectDir(project);
      if (projectDir != null) {
        return projectDir.getPath();
      }
    }

    return SystemProperties.getUserHome();
  }
private static String pathToSelect(FileChooserDescriptor descriptor, @Nullable Project project, @Nullable VirtualFile toSelect)