Java Code Examples for com.intellij.util.containers.ContainerUtil#union()

The following examples show how to use com.intellij.util.containers.ContainerUtil#union() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StructureFilterPopupComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void setVisible(@Nonnull VirtualFile root, boolean visible) {
  Set<VirtualFile> roots = getAllRoots();

  VcsLogFileFilter previousFilter = myFilterModel.getFilter();
  VcsLogRootFilter rootFilter = previousFilter != null ? previousFilter.getRootFilter() : null;

  Collection<VirtualFile> visibleRoots;
  if (rootFilter == null) {
    if (visible) {
      visibleRoots = roots;
    }
    else {
      visibleRoots = ContainerUtil.subtract(roots, Collections.singleton(root));
    }
  }
  else {
    if (visible) {
      visibleRoots = ContainerUtil.union(new HashSet<>(rootFilter.getRoots()), Collections.singleton(root));
    }
    else {
      visibleRoots = ContainerUtil.subtract(rootFilter.getRoots(), Collections.singleton(root));
    }
  }
  myFilterModel.setFilter(new VcsLogFileFilter(null, new VcsLogRootFilterImpl(visibleRoots)));
}
 
Example 2
Source File: FragmentGenerator.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public GreenFragment getGreenFragmentForCollapse(int startNode, int maxWalkSize) {
  if (myRedNodes.value(startNode)) return new GreenFragment(null, null, Collections.<Integer>emptySet());
  Integer upRedNode = getNearRedNode(startNode, maxWalkSize, true);
  Integer downRedNode = getNearRedNode(startNode, maxWalkSize, false);

  Set<Integer> upPart =
    upRedNode != null ? getMiddleNodes(upRedNode, startNode, false) : getWalkNodes(startNode, true, createStopFunction(maxWalkSize));

  Set<Integer> downPart =
    downRedNode != null ? getMiddleNodes(startNode, downRedNode, false) : getWalkNodes(startNode, false, createStopFunction(maxWalkSize));

  Set<Integer> middleNodes = ContainerUtil.union(upPart, downPart);
  if (upRedNode != null) middleNodes.remove(upRedNode);
  if (downRedNode != null) middleNodes.remove(downRedNode);

  return new GreenFragment(upRedNode, downRedNode, middleNodes);
}
 
Example 3
Source File: VcsDirtyScopeManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private VcsInvalidated calculateInvalidated(@Nonnull DirtBuilder dirt) {
  MultiMap<AbstractVcs, FilePath> files = dirt.getFilesForVcs();
  MultiMap<AbstractVcs, FilePath> dirs = dirt.getDirsForVcs();
  if (dirt.isEverythingDirty()) {
    dirs.putAllValues(getEverythingDirtyRoots());
  }
  Set<AbstractVcs> keys = ContainerUtil.union(files.keySet(), dirs.keySet());

  Map<AbstractVcs, VcsDirtyScopeImpl> scopes = ContainerUtil.newHashMap();
  for (AbstractVcs key : keys) {
    VcsDirtyScopeImpl scope = new VcsDirtyScopeImpl(key, myProject);
    scopes.put(key, scope);
    scope.addDirtyData(dirs.get(key), files.get(key));
  }

  return new VcsInvalidated(new ArrayList<>(scopes.values()), dirt.isEverythingDirty());
}
 
Example 4
Source File: TargetInfo.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public TargetInfo union(@NotNull TargetInfo other) {
  return new TargetInfo(
    ContainerUtil.union(getAddressInfos(), other.getAddressInfos()),
    ContainerUtil.union(getTargets(), other.getTargets()),
    ContainerUtil.union(getLibraries(), other.getLibraries()),
    ContainerUtil.union(getExcludes(), other.getExcludes()),
    ContainerUtil.union(getRoots(), other.getRoots())
  );
}
 
Example 5
Source File: VisiblePackBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private FilterResult filterByDetails(@Nonnull DataPack dataPack,
                                     @Nonnull VcsLogFilterCollection filters,
                                     @Nonnull CommitCountStage commitCount,
                                     @Nonnull Collection<VirtualFile> visibleRoots,
                                     @Nullable Set<Integer> matchingHeads) {
  List<VcsLogDetailsFilter> detailsFilters = filters.getDetailsFilters();
  if (detailsFilters.isEmpty()) return new FilterResult(null, false, commitCount);

  Set<Integer> filteredWidthIndex = null;
  if (myIndex.canFilter(detailsFilters)) {
    Collection<VirtualFile> notIndexedRoots = ContainerUtil.filter(visibleRoots, root -> !myIndex.isIndexed(root));

    if (notIndexedRoots.size() < visibleRoots.size()) {
      filteredWidthIndex = myIndex.filter(detailsFilters);
      if (notIndexedRoots.isEmpty()) return new FilterResult(filteredWidthIndex, false, commitCount);
      matchingHeads = getMatchingHeads(dataPack.getRefsModel(), notIndexedRoots, filters);
    }
  }

  FilterResult filteredWithVcs = filterWithVcs(dataPack.getPermanentGraph(), filters, detailsFilters, matchingHeads, commitCount);

  Set<Integer> filteredCommits;
  if (filteredWidthIndex == null) {
    filteredCommits = filteredWithVcs.matchingCommits;
  }
  else if (filteredWithVcs.matchingCommits == null) {
    filteredCommits = filteredWidthIndex;
  }
  else {
    filteredCommits = ContainerUtil.union(filteredWidthIndex, filteredWithVcs.matchingCommits);
  }
  return new FilterResult(filteredCommits, filteredWithVcs.canRequestMore, filteredWithVcs.commitCount);
}