Java Code Examples for com.intellij.util.containers.MultiMap#values()
The following examples show how to use
com.intellij.util.containers.MultiMap#values() .
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: MatchPatchPaths.java From consulo with Apache License 2.0 | 6 votes |
/** * Find the best matched bases for file patches; e.g. Unshelve has to use project dir as best base by default, * while Apply patch should process through context, because it may have been created outside IDE for a certain vcs root * * @param list * @param useProjectRootAsPredefinedBase if true then we use project dir as default base despite context matching * @return */ public List<AbstractFilePatchInProgress> execute(@Nonnull final List<? extends FilePatch> list, boolean useProjectRootAsPredefinedBase) { final PatchBaseDirectoryDetector directoryDetector = PatchBaseDirectoryDetector.getInstance(myProject); myUseProjectRootAsPredefinedBase = useProjectRootAsPredefinedBase; final List<PatchAndVariants> candidates = new ArrayList<>(list.size()); final List<FilePatch> newOrWithoutMatches = new ArrayList<>(); findCandidates(list, directoryDetector, candidates, newOrWithoutMatches); final MultiMap<VirtualFile, AbstractFilePatchInProgress> result = new MultiMap<>(); // process exact matches: if one, leave and extract. if several - leave only them filterExactMatches(candidates, result); // partially check by context selectByContextOrByStrip(candidates, result); // for text only // created or no variants workWithNotExisting(directoryDetector, newOrWithoutMatches, result); return new ArrayList<>(result.values()); }
Example 2
Source File: InjectedLanguageManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private ClassMapCachingNulls<MultiHostInjector> calcInjectorMap() { Map<Class<?>, MultiHostInjector[]> injectors = new HashMap<>(); MultiMap<Class<? extends PsiElement>, MultiHostInjector> allInjectors = new MultiMap<>(); for (MultiHostInjectorExtensionPoint extensionPoint : MultiHostInjector.EP_NAME.getExtensionList(myProject)) { allInjectors.putValue(extensionPoint.getKey(), extensionPoint.getInstance(myProject)); } if (LanguageInjector.EXTENSION_POINT_NAME.hasAnyExtensions()) { allInjectors.putValue(PsiLanguageInjectionHost.class, PsiManagerRegisteredInjectorsAdapter.INSTANCE); } for (Map.Entry<Class<? extends PsiElement>, Collection<MultiHostInjector>> injector : allInjectors.entrySet()) { Class<? extends PsiElement> place = injector.getKey(); Collection<MultiHostInjector> value = injector.getValue(); injectors.put(place, value.toArray(new MultiHostInjector[0])); } return new ClassMapCachingNulls<>(injectors, new MultiHostInjector[0], new ArrayList<>(allInjectors.values())); }
Example 3
Source File: ConflictsDialog.java From consulo with Apache License 2.0 | 6 votes |
public ConflictsDialog(@Nonnull Project project, @Nonnull MultiMap<PsiElement, String> conflictDescriptions, @Nullable Runnable doRefactoringRunnable, boolean alwaysShowOkButton, boolean canShowConflictsInView) { super(project, true); myProject = project; myDoRefactoringRunnable = doRefactoringRunnable; myCanShowConflictsInView = canShowConflictsInView; final LinkedHashSet<String> conflicts = new LinkedHashSet<String>(); for (String conflict : conflictDescriptions.values()) { conflicts.add(conflict); } myConflictDescriptions = ArrayUtil.toStringArray(conflicts); myElementConflictDescription = conflictDescriptions; setTitle(RefactoringBundle.message("problems.detected.title")); setOKButtonText(RefactoringBundle.message("continue.button")); setOKActionEnabled(alwaysShowOkButton || myDoRefactoringRunnable != null); init(); }
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: ApplyPatchDefaultExecutor.java From consulo with Apache License 2.0 | 5 votes |
public static Set<String> pathsFromGroups(MultiMap<VirtualFile, AbstractFilePatchInProgress> patchGroups) { final Set<String> selectedPaths = new HashSet<>(); final Collection<? extends AbstractFilePatchInProgress> values = patchGroups.values(); for (AbstractFilePatchInProgress value : values) { final String path = value.getPatch().getBeforeName() == null ? value.getPatch().getAfterName() : value.getPatch().getBeforeName(); selectedPaths.add(path); } return selectedPaths; }
Example 6
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 7
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; }