Java Code Examples for com.intellij.util.containers.ContainerUtil#intersection()
The following examples show how to use
com.intellij.util.containers.ContainerUtil#intersection() .
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: VisiblePackBuilder.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private Set<Integer> getMatchingHeads(@Nonnull VcsLogRefs refs, @Nonnull Collection<VirtualFile> roots, @Nonnull VcsLogFilterCollection filters) { VcsLogBranchFilter branchFilter = filters.getBranchFilter(); VcsLogRootFilter rootFilter = filters.getRootFilter(); VcsLogStructureFilter structureFilter = filters.getStructureFilter(); if (branchFilter == null && rootFilter == null && structureFilter == null) return null; Set<Integer> filteredByBranch = null; if (branchFilter != null) { filteredByBranch = getMatchingHeads(refs, branchFilter); } Set<Integer> filteredByFile = getMatchingHeads(refs, roots); if (filteredByBranch == null) return filteredByFile; if (filteredByFile == null) return filteredByBranch; return new HashSet<>(ContainerUtil.intersection(filteredByBranch, filteredByFile)); }
Example 2
Source File: VcsLogUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public static Set<VirtualFile> getAllVisibleRoots(@Nonnull Collection<VirtualFile> roots, @Nullable VcsLogRootFilter rootFilter, @Nullable VcsLogStructureFilter structureFilter) { if (rootFilter == null && structureFilter == null) return new HashSet<>(roots); Collection<VirtualFile> fromRootFilter; if (rootFilter != null) { fromRootFilter = rootFilter.getRoots(); } else { fromRootFilter = roots; } Collection<VirtualFile> fromStructureFilter; if (structureFilter != null) { fromStructureFilter = collectRoots(structureFilter.getFiles(), new HashSet<>(roots)); } else { fromStructureFilter = roots; } return new HashSet<>(ContainerUtil.intersection(fromRootFilter, fromStructureFilter)); }
Example 3
Source File: IgnoreCoverEntryInspection.java From idea-gitignore with MIT License | 4 votes |
/** * Reports problems at file level. Checks if entries are covered by other entries. * * @param file current working file to check * @param manager {@link InspectionManager} to ask for {@link ProblemDescriptor}'s from * @param isOnTheFly true if called during on the fly editor highlighting. Called from Inspect Code action otherwise * @return <code>null</code> if no problems found or not applicable at file level */ @Nullable @Override public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { final VirtualFile virtualFile = file.getVirtualFile(); if (!(file instanceof IgnoreFile) || !Utils.isInProject(virtualFile, file.getProject())) { return null; } final VirtualFile contextDirectory = virtualFile.getParent(); if (contextDirectory == null) { return null; } final Set<String> ignored = new HashSet<>(); final Set<String> unignored = new HashSet<>(); final ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly); final List<Pair<IgnoreEntry, IgnoreEntry>> result = new ArrayList<>(); final Map<IgnoreEntry, Set<String>> map = new HashMap<>(); final ArrayList<IgnoreEntry> entries = new ArrayList<>(Arrays.asList( ((IgnoreFile) file).findChildrenByClass(IgnoreEntry.class) )); final MatcherUtil matcher = IgnoreManager.getInstance(file.getProject()).getMatcher(); final Map<IgnoreEntry, Set<String>> matchedMap = getPathsSet(contextDirectory, entries, matcher); for (IgnoreEntry entry : entries) { ProgressManager.checkCanceled(); Set<String> matched = matchedMap.get(entry); Collection<String> intersection; boolean modified; if (!entry.isNegated()) { ignored.addAll(matched); intersection = ContainerUtil.intersection(unignored, matched); modified = unignored.removeAll(intersection); } else { unignored.addAll(matched); intersection = ContainerUtil.intersection(ignored, matched); modified = ignored.removeAll(intersection); } if (modified) { continue; } for (IgnoreEntry recent : map.keySet()) { ProgressManager.checkCanceled(); Set<String> recentValues = map.get(recent); if (recentValues.isEmpty() || matched.isEmpty()) { continue; } if (entry.isNegated() == recent.isNegated()) { if (recentValues.containsAll(matched)) { result.add(Pair.create(recent, entry)); } else if (matched.containsAll(recentValues)) { result.add(Pair.create(entry, recent)); } } else { if (intersection.containsAll(recentValues)) { result.add(Pair.create(entry, recent)); } } } map.put(entry, matched); } for (Pair<IgnoreEntry, IgnoreEntry> pair : result) { problemsHolder.registerProblem(pair.second, message(pair.first, virtualFile, isOnTheFly), new IgnoreRemoveEntryFix(pair.second)); } return problemsHolder.getResultsArray(); }