@Contract("_,null -> !null")
  private static @Nullable String getErrorIfBadFolderPathForStoringInArbitraryFile(@NotNull Project project,
                                                                                   @Nullable @NonNls @SystemIndependent String path) {
    if (getDotIdeaStoragePath(project).equals(path)) return null; // that's ok

    if (StringUtil.isEmpty(path)) return ExecutionBundle.message("run.configuration.storage.folder.path.not.specified");
    if (path.endsWith("/.idea") || path.contains("/.idea/")) {
      return ExecutionBundle.message("run.configuration.storage.folder.dot.idea.forbidden", File.separator);
    }

    VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
    if (file != null && !file.isDirectory()) return ExecutionBundle.message("run.configuration.storage.folder.path.expected");

    String folderName = PathUtil.getFileName(path);
    String parentPath = PathUtil.getParentPath(path);
    while (file == null && !parentPath.isEmpty()) {
      if (!PathUtil.isValidFileName(folderName)) {
        return ExecutionBundle.message("run.configuration.storage.folder.path.expected");
      }
      file = LocalFileSystem.getInstance().findFileByPath(parentPath);
      folderName = PathUtil.getFileName(parentPath);
      parentPath = PathUtil.getParentPath(parentPath);
    }

    if (file == null) return ExecutionBundle.message("run.configuration.storage.folder.not.within.project");
    if (!file.isDirectory()) return ExecutionBundle.message("run.configuration.storage.folder.path.expected");

    boolean isInContent = WorkspaceFileIndex.getInstance(project).isUrlInContent(VfsUtilCore.pathToUrl(path)) != ThreeState.NO;
    if (!isInContent) {
      if (ProjectFileIndex.getInstance(project).getContentRootForFile(file, false) == null) {
        return ExecutionBundle.message("run.configuration.storage.folder.not.within.project");
      }
      else {
        return ExecutionBundle.message("run.configuration.storage.folder.in.excluded.root");
      }
    }

    return null; // ok
  }
@Contract("_,null -> !null")
  private static @Nullable String getErrorIfBadFolderPathForStoringInArbitraryFile(@NotNull Project project,
                                                                                   @Nullable @NonNls @SystemIndependent String path)