Java Code Examples for com.intellij.util.containers.MultiMap#isEmpty()
The following examples show how to use
com.intellij.util.containers.MultiMap#isEmpty() .
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: VcsDirtyScopeManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void filePathsDirty(@Nullable final Collection<FilePath> filesDirty, @Nullable final Collection<FilePath> dirsRecursivelyDirty) { try { final MultiMap<AbstractVcs, FilePath> filesConverted = groupByVcs(filesDirty); final MultiMap<AbstractVcs, FilePath> dirsConverted = groupByVcs(dirsRecursivelyDirty); if (filesConverted.isEmpty() && dirsConverted.isEmpty()) return; if (LOG.isDebugEnabled()) { LOG.debug("dirty files: " + toString(filesConverted) + "; dirty dirs: " + toString(dirsConverted) + "; " + findFirstInterestingCallerClass()); } boolean hasSomethingDirty; synchronized (LOCK) { if (!myReady) return; markDirty(myDirtBuilder, filesConverted, false); markDirty(myDirtBuilder, dirsConverted, true); hasSomethingDirty = !myDirtBuilder.isEmpty(); } if (hasSomethingDirty) { myChangeListManager.scheduleUpdate(); } } catch (ProcessCanceledException ignore) { } }
Example 2
Source File: TreeModelBuilder.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public TreeModelBuilder setSwitchedFiles(@Nonnull MultiMap<String, VirtualFile> switchedFiles) { if (switchedFiles.isEmpty()) return this; ChangesBrowserNode subtreeRoot = createTagNode(ChangesBrowserNode.SWITCHED_FILES_TAG); for (String branchName : switchedFiles.keySet()) { List<VirtualFile> switchedFileList = ContainerUtil.sorted(switchedFiles.get(branchName), VirtualFileHierarchicalComparator.getInstance()); if (switchedFileList.size() > 0) { ChangesBrowserNode branchNode = ChangesBrowserNode.create(myProject, branchName); myModel.insertNodeInto(branchNode, subtreeRoot, subtreeRoot.getChildCount()); for (VirtualFile file : switchedFileList) { insertChangeNode(file, branchNode, ChangesBrowserNode.create(myProject, file)); } } } return this; }
Example 3
Source File: VcsAnnotationLocalChangesListenerImpl.java From consulo with Apache License 2.0 | 6 votes |
private void processUnderFile(VirtualFile file) { final MultiMap<VirtualFile, FileAnnotation> annotations = new MultiMap<>(); synchronized (myLock) { for (VirtualFile virtualFile : myFileAnnotationMap.keySet()) { if (VfsUtilCore.isAncestor(file, virtualFile, true)) { final Collection<FileAnnotation> values = myFileAnnotationMap.get(virtualFile); for (FileAnnotation value : values) { annotations.putValue(virtualFile, value); } } } } if (! annotations.isEmpty()) { for (Map.Entry<VirtualFile, Collection<FileAnnotation>> entry : annotations.entrySet()) { final VirtualFile key = entry.getKey(); final VcsRevisionNumber number = fromDiffProvider(key); if (number == null) continue; final Collection<FileAnnotation> fileAnnotations = entry.getValue(); for (FileAnnotation annotation : fileAnnotations) { if (annotation.isBaseRevisionChanged(number)) { annotation.close(); } } } } }
Example 4
Source File: BaseRefactoringProcessor.java From consulo with Apache License 2.0 | 6 votes |
protected boolean showConflicts(@Nonnull MultiMap<PsiElement, String> conflicts, @Nullable final UsageInfo[] usages) { if (!conflicts.isEmpty() && ApplicationManager.getApplication().isUnitTestMode()) { if (!ConflictsInTestsException.isTestIgnore()) throw new ConflictsInTestsException(conflicts.values()); return true; } if (myPrepareSuccessfulSwingThreadCallback != null && !conflicts.isEmpty()) { final String refactoringId = getRefactoringId(); if (refactoringId != null) { RefactoringEventData conflictUsages = new RefactoringEventData(); conflictUsages.putUserData(RefactoringEventData.CONFLICTS_KEY, conflicts.values()); myProject.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).conflictsDetected(refactoringId, conflictUsages); } final ConflictsDialog conflictsDialog = prepareConflictsDialog(conflicts, usages); if (!conflictsDialog.showAndGet()) { if (conflictsDialog.isShowConflicts()) prepareSuccessful(); return false; } } prepareSuccessful(); return true; }
Example 5
Source File: Unity3dAssetEditorNotificationProvider.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@RequiredReadAction @Nullable @Override public EditorNotificationPanel createNotificationPanel(@Nonnull VirtualFile file, @Nonnull FileEditor fileEditor) { if(file.getFileType() != Unity3dYMLAssetFileType.INSTANCE || !ArrayUtil.contains(file.getExtension(), Unity3dAssetFileTypeDetector.ourAssetExtensions)) { return null; } final String uuid = Unity3dAssetUtil.getGUID(myProject, file); if(uuid == null) { return null; } MultiMap<VirtualFile, Unity3dYMLAsset> map = Unity3dYMLAsset.findAssetAsAttach(myProject, file); if(map.isEmpty()) { return null; } PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file); if(psiFile == null) { return null; } final EditorNotificationPanel panel = new EditorNotificationPanel(); panel.text("Used asset..."); panel.createActionLabel("Find usages...", () -> FindManager.getInstance(myProject).findUsages(psiFile)); return panel; }
Example 6
Source File: Unity3dConsoleManager.java From consulo-unity3d with Apache License 2.0 | 5 votes |
private void pop() { MultiMap<String, UnityLogPostHandlerRequest> map = MultiMap.empty(); while(!myMessages.isEmpty()) { UnityLogPostHandlerRequest request = myMessages.pollFirst(); if(request == null) { continue; } if(map.isEmpty()) { map = MultiMap.createLinkedSet(); } map.putValue(request.projectPath, request); } if(map.isEmpty()) { return; } for(Map.Entry<String, Collection<UnityLogPostHandlerRequest>> entry : map.entrySet()) { Project projectByPath = Unity3dProjectUtil.findProjectByPath(entry.getKey()); if(projectByPath == null) { continue; } Collection<Consumer<Collection<UnityLogPostHandlerRequest>>> consumers = myMap.get(projectByPath); for(Consumer<Collection<UnityLogPostHandlerRequest>> consumer : consumers) { consumer.accept(entry.getValue()); } } }
Example 7
Source File: MapElementGroupCollector.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nullable @Override @RequiredReadAction protected Map<K, CSharpElementGroup<E>> compute() { MultiMap<K, E> elements = calcElements(); final Map<K, CSharpElementGroup<E>> map; if(elements.isEmpty()) { map = null; } else { map = new LinkedHashMap<>(); final DotNetGenericExtractor extractor = getExtractor(); final DotNetModifierListOwner parent = myResolveContext.getElement(); final Project project = getProject(); for(Map.Entry<K, Collection<E>> entry : elements.entrySet()) { K key = entry.getKey(); Collection<E> value = entry.getValue(); if(extractor != DotNetGenericExtractor.EMPTY) { value = ContainerUtil.map(value, element -> element instanceof DotNetNamedElement ? (E) GenericUnwrapTool.extract((DotNetNamedElement) element, extractor, parent) : element); } CSharpElementGroup<E> group = new CSharpElementGroupImpl<>(project, key, value); map.put(key, group); } } return map; }
Example 8
Source File: MapElementGroupCollector.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nonnull @RequiredReadAction @SuppressWarnings("unchecked") private MultiMap<K, E> calcElements() { final MultiMap<K, E> multiMap = MultiMap.createLinked(); Consumer consumer = e -> { K keyForElement = getKeyForElement((E) e); if(keyForElement == null) { return; } multiMap.getModifiable(keyForElement).add((E) e); }; CSharpElementVisitor visitor = createVisitor(consumer); myResolveContext.acceptChildren(visitor); for(CSharpAdditionalMemberProvider memberProvider : CSharpAdditionalMemberProvider.EP_NAME.getExtensionList()) { if(memberProvider.getTarget() == myTarget) { memberProvider.processAdditionalMembers(myResolveContext.getElement(), getExtractor(), consumer); } } if(multiMap.isEmpty()) { return MultiMap.empty(); } return multiMap; }
Example 9
Source File: ExtractSuperClassUtil.java From intellij-haxe with Apache License 2.0 | 5 votes |
public static boolean showConflicts(DialogWrapper dialog, MultiMap<PsiElement, String> conflicts, final Project project) { if (!conflicts.isEmpty()) { fireConflictsEvent(conflicts, project); ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts); conflictsDialog.show(); final boolean ok = conflictsDialog.isOK(); if (!ok && conflictsDialog.isShowConflicts()) dialog.close(DialogWrapper.CANCEL_EXIT_CODE); return ok; } return true; }
Example 10
Source File: HaxePullUpHandler.java From intellij-haxe with Apache License 2.0 | 5 votes |
@Override public boolean checkConflicts(final HaxePullUpDialog dialog) { final List<MemberInfo> infos = dialog.getSelectedMemberInfos(); final MemberInfo[] memberInfos = infos.toArray(new MemberInfo[infos.size()]); final PsiClass superClass = dialog.getSuperClass(); if (!checkWritable(superClass, memberInfos)) return false; final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>(); if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { //final PsiDirectory targetDirectory = superClass.getContainingFile().getContainingDirectory(); //final PsiPackage targetPackage = targetDirectory != null ? JavaDirectoryService.getInstance().getPackage(targetDirectory) : null; //conflicts // .putAllValues(PullUpConflictsUtil.checkConflicts(memberInfos, mySubclass, superClass, targetPackage, targetDirectory, // dialog.getContainmentVerifier())); } }); } }, RefactoringBundle.message("detecting.possible.conflicts"), true, myProject)) return false; if (!conflicts.isEmpty()) { ConflictsDialog conflictsDialog = new ConflictsDialog(myProject, conflicts); conflictsDialog.show(); final boolean ok = conflictsDialog.isOK(); if (!ok && conflictsDialog.isShowConflicts()) dialog.close(DialogWrapper.CANCEL_EXIT_CODE); return ok; } return true; }
Example 11
Source File: SimpleRefGroup.java From consulo with Apache License 2.0 | 5 votes |
public static void buildGroups(@Nonnull MultiMap<VcsRefType, VcsRef> groupedRefs, boolean compact, boolean showTagNames, @Nonnull List<RefGroup> result) { if (groupedRefs.isEmpty()) return; if (compact) { VcsRef firstRef = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(groupedRefs.values())); RefGroup group = ContainerUtil.getFirstItem(result); if (group == null) { result.add(new SimpleRefGroup(firstRef.getType().isBranch() || showTagNames ? firstRef.getName() : "", ContainerUtil.newArrayList(groupedRefs.values()))); } else { group.getRefs().addAll(groupedRefs.values()); } } else { for (Map.Entry<VcsRefType, Collection<VcsRef>> entry : groupedRefs.entrySet()) { if (entry.getKey().isBranch()) { for (VcsRef ref : entry.getValue()) { result.add(new SimpleRefGroup(ref.getName(), ContainerUtil.newArrayList(ref))); } } else { result.add(new SimpleRefGroup(showTagNames ? ObjectUtils.notNull(ContainerUtil.getFirstItem(entry.getValue())).getName() : "", ContainerUtil.newArrayList(entry.getValue()))); } } } }
Example 12
Source File: CompletionLookupArrangerImpl.java From consulo with Apache License 2.0 | 5 votes |
private Iterable<LookupElement> sortByRelevance(MultiMap<CompletionSorterImpl, LookupElement> inputBySorter) { if (inputBySorter.isEmpty()) return Collections.emptyList(); final List<Iterable<LookupElement>> byClassifier = new ArrayList<>(); for (CompletionSorterImpl sorter : myClassifiers.keySet()) { ProcessingContext context = createContext(); byClassifier.add(myClassifiers.get(sorter).classify(inputBySorter.get(sorter), context)); } //noinspection unchecked return ContainerUtil.concat(byClassifier.toArray(new Iterable[0])); }
Example 13
Source File: ListTemplatesHandler.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void invoke(@Nonnull final Project project, @Nonnull final Editor editor, @Nonnull PsiFile file) { if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return; if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) { return; } EditorUtil.fillVirtualSpaceUntilCaret(editor); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); int offset = editor.getCaretModel().getOffset(); List<TemplateImpl> applicableTemplates = TemplateManagerImpl.listApplicableTemplateWithInsertingDummyIdentifier(editor, file, false); Map<TemplateImpl, String> matchingTemplates = filterTemplatesByPrefix(applicableTemplates, editor, offset, false, true); MultiMap<String, CustomLiveTemplateLookupElement> customTemplatesLookupElements = getCustomTemplatesLookupItems(editor, file, offset); if (matchingTemplates.isEmpty()) { for (TemplateImpl template : applicableTemplates) { matchingTemplates.put(template, null); } } if (matchingTemplates.isEmpty() && customTemplatesLookupElements.isEmpty()) { HintManager.getInstance().showErrorHint(editor, CodeInsightBundle.message("templates.no.defined")); return; } showTemplatesLookup(project, editor, file, matchingTemplates, customTemplatesLookupElements); }
Example 14
Source File: BaseRefactoringProcessor.java From consulo with Apache License 2.0 | 5 votes |
/** * Processes conflicts (possibly shows UI). In case we're running in unit test mode this method will * throw {@link BaseRefactoringProcessor.ConflictsInTestsException} that can be handled inside a test. * Thrown exception would contain conflicts' messages. * * @param project project * @param conflicts map with conflict messages and locations * @return true if refactoring could proceed or false if refactoring should be cancelled */ public static boolean processConflicts(@Nonnull Project project, @Nonnull MultiMap<PsiElement, String> conflicts) { if (conflicts.isEmpty()) return true; if (ApplicationManager.getApplication().isUnitTestMode()) { if (BaseRefactoringProcessor.ConflictsInTestsException.isTestIgnore()) return true; throw new BaseRefactoringProcessor.ConflictsInTestsException(conflicts.values()); } ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts); return conflictsDialog.showAndGet(); }
Example 15
Source File: PsiSearchHelperImpl.java From consulo with Apache License 2.0 | 4 votes |
private boolean processGlobalRequestsOptimized(@Nonnull MultiMap<Set<IdIndexEntry>, RequestWithProcessor> singles, @Nonnull ProgressIndicator progress, @Nonnull final Map<RequestWithProcessor, Processor<PsiElement>> localProcessors) { if (singles.isEmpty()) { return true; } if (singles.size() == 1) { final Collection<? extends RequestWithProcessor> requests = singles.values(); if (requests.size() == 1) { final RequestWithProcessor theOnly = requests.iterator().next(); return processSingleRequest(theOnly.request, theOnly.refProcessor); } } progress.pushState(); progress.setText(PsiBundle.message("psi.scanning.files.progress")); boolean result; try { // intersectionCandidateFiles holds files containing words from all requests in `singles` and words in corresponding container names final MultiMap<VirtualFile, RequestWithProcessor> intersectionCandidateFiles = createMultiMap(); // restCandidateFiles holds files containing words from all requests in `singles` but EXCLUDING words in corresponding container names final MultiMap<VirtualFile, RequestWithProcessor> restCandidateFiles = createMultiMap(); collectFiles(singles, progress, intersectionCandidateFiles, restCandidateFiles); if (intersectionCandidateFiles.isEmpty() && restCandidateFiles.isEmpty()) { return true; } final Set<String> allWords = new TreeSet<>(); for (RequestWithProcessor singleRequest : localProcessors.keySet()) { allWords.add(singleRequest.request.word); } progress.setText(PsiBundle.message("psi.search.for.word.progress", getPresentableWordsDescription(allWords))); if (intersectionCandidateFiles.isEmpty()) { result = processCandidates(localProcessors, restCandidateFiles, progress, restCandidateFiles.size(), 0); } else { int totalSize = restCandidateFiles.size() + intersectionCandidateFiles.size(); result = processCandidates(localProcessors, intersectionCandidateFiles, progress, totalSize, 0); if (result) { result = processCandidates(localProcessors, restCandidateFiles, progress, totalSize, intersectionCandidateFiles.size()); } } } finally { progress.popState(); } return result; }