public static List processByWorkspaces()

in src/org/jetbrains/tfsIntegration/core/tfs/WorkstationHelper.java [41:83]


  public static List<FilePath> processByWorkspaces(Collection<? extends FilePath> localPaths,
                                                   boolean considerChildMappings,
                                                   Object projectOrComponent,
                                                   VoidProcessDelegate processor) throws TfsException {
    List<FilePath> orphanPaths = new ArrayList<>();
    Map<WorkspaceInfo, List<FilePath>> workspace2localPaths = new HashMap<>();
    for (FilePath localPath : localPaths) {
      Collection<WorkspaceInfo> workspaces = Workstation.getInstance().findWorkspaces(localPath, considerChildMappings, projectOrComponent);
      if (!workspaces.isEmpty()) {
        for (WorkspaceInfo workspace : workspaces) {
          List<FilePath> workspaceLocalPaths = workspace2localPaths.get(workspace);
          if (workspaceLocalPaths == null) {
            workspaceLocalPaths = new ArrayList<>();
            workspace2localPaths.put(workspace, workspaceLocalPaths);
          }
          workspaceLocalPaths.add(localPath);
        }
      }
      else {
        orphanPaths.add(localPath);
      }
    }

    for (WorkspaceInfo workspace : workspace2localPaths.keySet()) {
      List<FilePath> currentLocalPaths = workspace2localPaths.get(workspace);
      List<ItemPath> currentItemPaths = new ArrayList<>(currentLocalPaths.size());
      for (FilePath localPath : currentLocalPaths) {
        Collection<String> serverPaths = workspace.findServerPathsByLocalPath(localPath, considerChildMappings, projectOrComponent);
        if (!considerChildMappings) {
          currentItemPaths.add(new ItemPath(localPath, serverPaths.iterator().next()));
        }
        else {
          for (String serverPath : serverPaths) {
            //noinspection ConstantConditions
            currentItemPaths.add(
              new ItemPath(workspace.findLocalPathByServerPath(serverPath, localPath.isDirectory(), projectOrComponent), serverPath));
          }
        }
      }
      processor.executeRequest(workspace, currentItemPaths);
    }
    return orphanPaths;
  }