use of com.intellij.util.containers.MultiMap in project android by JetBrains.
the class ChooseResourceDialog method initializeThemeAttributes.
private static MultiMap<ResourceType, String> initializeThemeAttributes(@NotNull Configuration configuration, @NotNull ResourceResolver resolver) {
MultiMap<ResourceType, String> attrs = new MultiMap<>();
String themeName = configuration.getTheme();
assert themeName != null;
for (ItemResourceValue item : ResolutionUtils.getThemeAttributes(resolver, themeName)) {
ResourceType type = ResolutionUtils.getAttrType(item, configuration);
if (type != null) {
attrs.putValue(type, ResolutionUtils.getQualifiedItemName(item));
}
}
return attrs;
}
use of com.intellij.util.containers.MultiMap in project intellij-plugins by JetBrains.
the class FlexMoveClassProcessor method detectConflicts.
private MultiMap<PsiElement, String> detectConflicts(UsageInfo[] usages) {
MultiMap<PsiElement, String> conflicts = new MultiMap<>();
final Collection<PsiElement> filesToMove = Arrays.asList(myElementsToMove);
JSVisibilityUtil.Options options = new JSVisibilityUtil.Options();
for (PsiElement file : filesToMove) {
options.overridePackage(file, myTargetPackage);
}
for (UsageInfo usage : usages) {
final PsiElement element = usage.getElement();
if (!(element instanceof JSReferenceExpression)) {
continue;
}
if (CommonRefactoringUtil.isAncestor(element, filesToMove)) {
continue;
}
JSReferenceExpression refExpr = (JSReferenceExpression) element;
final PsiElement resolved = refExpr.resolve();
if (!(resolved instanceof JSQualifiedNamedElement)) {
continue;
}
PsiElement containingClass = null;
if (resolved instanceof JSFunction && ((JSFunction) resolved).isConstructor() && myElements.contains(containingClass = resolved.getParent()) || myElements.contains(resolved)) {
JSRefactoringConflictsUtil.checkAccessibility((JSAttributeListOwner) resolved, (JSClass) containingClass, null, refExpr, conflicts, true, options);
}
}
for (PsiElement fileToMove : filesToMove) {
JSRefactoringConflictsUtil.checkOutgoingReferencesAccessibility(fileToMove, filesToMove, null, true, conflicts, Conditions.alwaysTrue(), options);
}
//JSRefactoringConflictsUtil.analyzeModuleConflicts(myProject, myElements, usages, myTargetDirectory, conflicts);
return conflicts;
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class VcsDirtyScopeImpl method addDirtyData.
public void addDirtyData(@NotNull Collection<FilePath> dirs, @NotNull Collection<FilePath> files) {
final HashSet<FilePath> newFiles = new HashSet<>(files);
// if the same dir is added recursively and not recursively, prefer recursive mark
newFiles.removeAll(dirs);
final MultiMap<VirtualFile, FileOrDir> perRoot = MultiMap.createSet();
for (Map.Entry<VirtualFile, THashSet<FilePath>> entry : myDirtyDirectoriesRecursively.entrySet()) {
// if the same dir is added recursively and not recursively, prefer recursive mark
newFiles.removeAll(entry.getValue());
for (FilePath path : entry.getValue()) {
perRoot.putValue(entry.getKey(), new FileOrDir(path, true));
}
}
for (Map.Entry<VirtualFile, THashSet<FilePath>> entry : myDirtyFiles.entrySet()) {
for (FilePath path : entry.getValue()) {
perRoot.putValue(entry.getKey(), new FileOrDir(path, false));
}
}
for (FilePath dir : dirs) {
addFilePathToMap(perRoot, dir, true);
}
for (FilePath file : newFiles) {
addFilePathToMap(perRoot, file, false);
}
for (Map.Entry<VirtualFile, Collection<FileOrDir>> entry : perRoot.entrySet()) {
final Collection<FileOrDir> set = entry.getValue();
final Collection<FileOrDir> newCollection = FileUtil.removeAncestors(set, new Convertor<FileOrDir, String>() {
@Override
public String convert(FileOrDir o) {
return o.myPath.getPath();
}
}, new PairProcessor<FileOrDir, FileOrDir>() {
@Override
public boolean process(FileOrDir parent, FileOrDir child) {
if (parent.myRecursive) {
return true;
}
// if under non-recursive dirty dir, generally do not remove child with one exception...
if (child.myRecursive || child.myPath.isDirectory()) {
return false;
}
// only if dir non-recursively + non-recursive file child -> can be truncated to dir only
return Comparing.equal(child.myPath.getParentPath(), parent.myPath);
}
});
set.retainAll(newCollection);
}
myAffectedContentRoots.addAll(perRoot.keySet());
for (Map.Entry<VirtualFile, Collection<FileOrDir>> entry : perRoot.entrySet()) {
final VirtualFile root = entry.getKey();
final THashSet<FilePath> curFiles = newFilePathsSet();
final THashSet<FilePath> curDirs = newFilePathsSet();
final Collection<FileOrDir> value = entry.getValue();
for (FileOrDir fileOrDir : value) {
if (fileOrDir.myRecursive) {
curDirs.add(fileOrDir.myPath);
} else {
curFiles.add(fileOrDir.myPath);
}
}
// also, we replace contents, so here's no merging
if (!curDirs.isEmpty()) {
myDirtyDirectoriesRecursively.put(root, curDirs);
}
if (!curFiles.isEmpty()) {
myDirtyFiles.put(root, curFiles);
}
}
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class AttachToLocalProcessAction method collectAttachItems.
@NotNull
public static List<AttachItem> collectAttachItems(@NotNull final Project project, @NotNull ProcessInfo[] processList, @NotNull ProgressIndicator indicator, @NotNull XLocalAttachDebuggerProvider... providers) {
MultiMap<XLocalAttachGroup, Pair<ProcessInfo, ArrayList<XLocalAttachDebugger>>> groupWithItems = new MultiMap<>();
UserDataHolderBase dataHolder = new UserDataHolderBase();
for (ProcessInfo eachInfo : processList) {
MultiMap<XLocalAttachGroup, XLocalAttachDebugger> groupsWithDebuggers = new MultiMap<>();
for (XLocalAttachDebuggerProvider eachProvider : providers) {
indicator.checkCanceled();
groupsWithDebuggers.putValues(eachProvider.getAttachGroup(), eachProvider.getAvailableDebuggers(project, eachInfo, dataHolder));
}
for (XLocalAttachGroup eachGroup : groupsWithDebuggers.keySet()) {
Collection<XLocalAttachDebugger> debuggers = groupsWithDebuggers.get(eachGroup);
if (!debuggers.isEmpty()) {
groupWithItems.putValue(eachGroup, Pair.create(eachInfo, new ArrayList<>(debuggers)));
}
}
}
ArrayList<XLocalAttachGroup> sortedGroups = new ArrayList<>(groupWithItems.keySet());
sortedGroups.sort(Comparator.comparingInt(XLocalAttachGroup::getOrder));
List<AttachItem> currentItems = new ArrayList<>();
for (final XLocalAttachGroup eachGroup : sortedGroups) {
List<Pair<ProcessInfo, ArrayList<XLocalAttachDebugger>>> sortedItems = new ArrayList<>(groupWithItems.get(eachGroup));
sortedItems.sort((a, b) -> eachGroup.compare(project, a.first, b.first, dataHolder));
boolean first = true;
for (Pair<ProcessInfo, ArrayList<XLocalAttachDebugger>> eachItem : sortedItems) {
currentItems.add(new AttachItem(eachGroup, first, eachItem.first, eachItem.second, dataHolder));
first = false;
}
}
List<AttachItem> currentHistoryItems = new ArrayList<>();
List<HistoryItem> history = getHistory(project);
for (int i = history.size() - 1; i >= 0; i--) {
HistoryItem eachHistoryItem = history.get(i);
for (AttachItem eachCurrentItem : currentItems) {
boolean isSuitableItem = eachHistoryItem.getGroup().equals(eachCurrentItem.getGroup()) && eachHistoryItem.getProcessInfo().getCommandLine().equals(eachCurrentItem.getProcessInfo().getCommandLine());
if (!isSuitableItem)
continue;
List<XLocalAttachDebugger> debuggers = eachCurrentItem.getDebuggers();
int selectedDebugger = -1;
for (int j = 0; j < debuggers.size(); j++) {
XLocalAttachDebugger eachDebugger = debuggers.get(j);
if (eachDebugger.getDebuggerDisplayName().equals(eachHistoryItem.getDebuggerName())) {
selectedDebugger = j;
break;
}
}
if (selectedDebugger == -1)
continue;
currentHistoryItems.add(new AttachItem(eachCurrentItem.getGroup(), currentHistoryItems.isEmpty(), XDebuggerBundle.message("xdebugger.attach.toLocal.popup.recent"), eachCurrentItem.getProcessInfo(), debuggers, selectedDebugger, dataHolder));
}
}
currentHistoryItems.addAll(currentItems);
return currentHistoryItems;
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class ProjectLoadingErrorsNotifierImpl method fireNotifications.
private void fireNotifications() {
final MultiMap<ConfigurationErrorType, ConfigurationErrorDescription> descriptionsMap = new MultiMap<>();
synchronized (myLock) {
if (myErrors.isEmpty())
return;
descriptionsMap.putAllValues(myErrors);
myErrors.clear();
}
for (final ConfigurationErrorType type : descriptionsMap.keySet()) {
final Collection<ConfigurationErrorDescription> descriptions = descriptionsMap.get(type);
if (descriptions.isEmpty())
continue;
final String invalidElements = getInvalidElementsString(type, descriptions);
final String errorText = ProjectBundle.message("error.message.configuration.cannot.load") + " " + invalidElements + " <a href=\"\">Details...</a>";
Notifications.Bus.notify(new Notification("Project Loading Error", "Error Loading Project", errorText, NotificationType.ERROR, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
final List<ConfigurationErrorDescription> validDescriptions = ContainerUtil.findAll(descriptions, errorDescription -> errorDescription.isValid());
if (RemoveInvalidElementsDialog.showDialog(myProject, CommonBundle.getErrorTitle(), type, invalidElements, validDescriptions)) {
notification.expire();
}
}
}), myProject);
}
}
Aggregations