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

The following examples show how to use com.intellij.util.containers.ContainerUtil#intersects() . 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: MultipleChangeListBrowser.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void setInitialSelection(@Nonnull List<? extends ChangeList> changeLists,
                                   @Nonnull List<Object> changes,
                                   @javax.annotation.Nullable ChangeList initialListSelection) {
  myAllChanges = ContainerUtil.newArrayList();
  mySelectedChangeList = initialListSelection;

  for (ChangeList list : changeLists) {
    if (list instanceof LocalChangeList) {
      myAllChanges.addAll(list.getChanges());
      if (initialListSelection == null && ContainerUtil.intersects(list.getChanges(), changes)) {
        mySelectedChangeList = list;
      }
    }
  }

  if (mySelectedChangeList == null) {
    mySelectedChangeList = ObjectUtils.chooseNotNull(findDefaultList(changeLists), ContainerUtil.getFirstItem(changeLists));
  }
}
 
Example 2
Source File: LibraryPresentationManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public List<Library> getLibraries(@Nonnull Set<LibraryKind> kinds, @Nonnull Project project, @Nullable StructureConfigurableContext context) {
  List<Library> libraries = new ArrayList<>();
  if (context != null) {
    Collections.addAll(libraries, context.getProjectLibrariesProvider().getModifiableModel().getLibraries());
    Collections.addAll(libraries, context.getGlobalLibrariesProvider().getModifiableModel().getLibraries());
  }
  else {
    final LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
    Collections.addAll(libraries, registrar.getLibraryTable(project).getLibraries());
    Collections.addAll(libraries, registrar.getLibraryTable().getLibraries());
  }

  final Iterator<Library> iterator = libraries.iterator();
  while (iterator.hasNext()) {
    Library library = iterator.next();
    final List<LibraryKind> libraryKinds = getLibraryKinds(library, context);
    if (!ContainerUtil.intersects(libraryKinds, kinds)) {
      iterator.remove();
    }
  }
  return libraries;
}
 
Example 3
Source File: ModuleCompilerUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
public static List<Chunk<Module>> getSortedModuleChunks(Project project, List<Module> modules) {
  final Module[] allModules = ModuleManager.getInstance(project).getModules();
  final List<Chunk<Module>> chunks = getSortedChunks(createModuleGraph(allModules));

  final Set<Module> modulesSet = new HashSet<Module>(modules);
  // leave only those chunks that contain at least one module from modules
  for (Iterator<Chunk<Module>> it = chunks.iterator(); it.hasNext();) {
    final Chunk<Module> chunk = it.next();
    if (!ContainerUtil.intersects(chunk.getNodes(), modulesSet)) {
      it.remove();
    }
  }
  return chunks;
}
 
Example 4
Source File: VisiblePackBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean matchesAnyHead(@Nonnull PermanentGraph<Integer> permanentGraph,
                               @Nonnull VcsCommitMetadata commit,
                               @Nullable Set<Integer> matchingHeads) {
  if (matchingHeads == null) {
    return true;
  }
  // TODO O(n^2)
  int commitIndex = myHashMap.getCommitIndex(commit.getId(), commit.getRoot());
  return ContainerUtil.intersects(permanentGraph.getContainingBranches(commitIndex), matchingHeads);
}
 
Example 5
Source File: DetailsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDetailsLoaded(@Nonnull List<VcsFullCommitDetails> detailsList) {
  Set<VcsFullCommitDetails> newCommitDetails = ContainerUtil.newHashSet(detailsList);
  for (int i = 0; i < mySelection.size(); i++) {
    CommitPanel commitPanel = getCommitPanel(i);
    commitPanel.setCommit(detailsList.get(i));
  }

  if (!ContainerUtil.intersects(myCommitDetails, newCommitDetails)) {
    myScrollPane.getVerticalScrollBar().setValue(0);
  }
  myCommitDetails = newCommitDetails;
}
 
Example 6
Source File: IdempotenceChecker.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static boolean objectsOfDifferentClassesCanStillBeEquivalent(@Nonnull Object existing, @Nonnull Object fresh) {
  if (existing instanceof Map && fresh instanceof Map && isOrderedMap(existing) == isOrderedMap(fresh)) return true;
  if (existing instanceof Set && fresh instanceof Set && isOrderedSet(existing) == isOrderedSet(fresh)) return true;
  if (existing instanceof List && fresh instanceof List) return true;
  return ContainerUtil.intersects(allSupersWithEquals.get(existing.getClass()), allSupersWithEquals.get(fresh.getClass()));
}