Java Code Examples for com.intellij.util.containers.ContainerUtil#newConcurrentMap()
The following examples show how to use
com.intellij.util.containers.ContainerUtil#newConcurrentMap() .
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: IgnoreManager.java From idea-gitignore with MIT License | 5 votes |
/** * Rebuilds {@link #confirmedIgnoredFiles} map. * * @param silent propagate {@link IgnoreManager.TrackedIgnoredListener#TRACKED_IGNORED} event */ public void run(boolean silent) { final ConcurrentMap<VirtualFile, VcsRoot> result = ContainerUtil.newConcurrentMap(); for (VcsRoot vcsRoot : vcsRoots) { if (!Utils.isGitPluginEnabled() || !(vcsRoot.getVcs() instanceof GitVcs)) { continue; } final VirtualFile root = vcsRoot.getPath(); for (String path : ExternalExec.getIgnoredFiles(vcsRoot)) { final VirtualFile file = root.findFileByRelativePath(path); if (file != null) { result.put(file, vcsRoot); } } } if (!silent && !result.isEmpty()) { project.getMessageBus().syncPublisher(TRACKED_IGNORED).handleFiles(result); } confirmedIgnoredFiles.clear(); confirmedIgnoredFiles.putAll(result); notConfirmedIgnoredFiles.clear(); debouncedStatusesChanged.run(); for (AbstractProjectViewPane pane : AbstractProjectViewPane.EP_NAME.getExtensions()) { if (pane.getTreeBuilder() != null) { pane.getTreeBuilder().queueUpdate(); } } }
Example 2
Source File: DocumentMarkupModel.java From consulo with Apache License 2.0 | 5 votes |
private static ConcurrentMap<Project, MarkupModelImpl> getMarkupModelMap(@Nonnull Document document) { ConcurrentMap<Project, MarkupModelImpl> markupModelMap = document.getUserData(MARKUP_MODEL_MAP_KEY); if (markupModelMap == null) { ConcurrentMap<Project, MarkupModelImpl> newMap = ContainerUtil.newConcurrentMap(); markupModelMap = ((UserDataHolderEx)document).putUserDataIfAbsent(MARKUP_MODEL_MAP_KEY, newMap); } return markupModelMap; }
Example 3
Source File: IgnoreCoverEntryInspection.java From idea-gitignore with MIT License | 4 votes |
/** * Builds a new instance of {@link IgnoreCoverEntryInspection}. * Initializes {@link VirtualFileManager} and listens for the changes in the files tree. */ public IgnoreCoverEntryInspection() { cacheMap = ContainerUtil.newConcurrentMap(); virtualFileManager = VirtualFileManager.getInstance(); virtualFileManager.addVirtualFileListener(virtualFileListener); }
Example 4
Source File: Glob.java From idea-gitignore with MIT License | 4 votes |
/** * Finds for {@link VirtualFile} list using glob rule in given root directory. * * @param root root directory * @param entries ignore entries * @param includeNested attach children to the search result * @return search result */ @NotNull public static Map<IgnoreEntry, List<VirtualFile>> find(@NotNull final VirtualFile root, @NotNull List<IgnoreEntry> entries, @NotNull final MatcherUtil matcher, final boolean includeNested) { final ConcurrentMap<IgnoreEntry, List<VirtualFile>> result = ContainerUtil.newConcurrentMap(); final HashMap<IgnoreEntry, Pattern> map = new HashMap<>(); for (IgnoreEntry entry : entries) { result.put(entry, new ArrayList<>()); final Pattern pattern = createPattern(entry); if (pattern != null) { map.put(entry, pattern); } } VirtualFileVisitor<HashMap<IgnoreEntry, Pattern>> visitor = new VirtualFileVisitor<HashMap<IgnoreEntry, Pattern>>(VirtualFileVisitor.NO_FOLLOW_SYMLINKS) { @Override public boolean visitFile(@NotNull VirtualFile file) { if (root.equals(file)) { return true; } final HashMap<IgnoreEntry, Pattern> current = new HashMap<>(); if (getCurrentValue().isEmpty()) { return false; } final String path = Utils.getRelativePath(root, file); if (path == null || Utils.isVcsDirectory(file)) { return false; } for (Map.Entry<IgnoreEntry, Pattern> item : getCurrentValue().entrySet()) { final Pattern value = item.getValue(); boolean matches = false; if (value == null || matcher.match(value, path)) { matches = true; result.get(item.getKey()).add(file); } if (includeNested && matches) { current.put(item.getKey(), null); } else { current.put(item.getKey(), item.getValue()); } } setValueForChildren(current); return true; } }; visitor.setValueForChildren(map); VfsUtil.visitChildrenRecursively(root, visitor); return result; }
Example 5
Source File: IgnoreReferenceSet.java From idea-gitignore with MIT License | 4 votes |
/** * Builds an instance of {@link IgnoreReferenceSet.IgnoreReference}. */ public IgnoreReference(@NotNull FileReferenceSet fileReferenceSet, TextRange range, int index, String text) { super(fileReferenceSet, range, index, text); cacheMap = ContainerUtil.newConcurrentMap(); }
Example 6
Source File: FilesIndexCacheProjectComponent.java From idea-gitignore with MIT License | 4 votes |
/** * Initializes {@link #cacheMap} and {@link VirtualFileManager}. * * @param project current project */ protected FilesIndexCacheProjectComponent(@NotNull final Project project) { this.cacheMap = ContainerUtil.newConcurrentMap(); this.virtualFileManager = VirtualFileManager.getInstance(); this.projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); }
Example 7
Source File: CanonicalPathMap.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static Map<String, String> resolvePaths(@Nonnull Collection<String> recursiveRoots, @Nonnull Collection<String> flatRoots) { Map<String, String> result = ContainerUtil.newConcurrentMap(); Stream.concat(recursiveRoots.stream(), flatRoots.stream()).parallel().forEach(root -> ContainerUtil.putIfNotNull(root, FileSystemUtil.resolveSymLink(root), result)); return result; }
Example 8
Source File: CommittedChangesCache.java From consulo with Apache License 2.0 | 4 votes |
@Inject public CommittedChangesCache(final Project project, final ProjectLevelVcsManager vcsManager) { myProject = project; myVcsManager = vcsManager; myBus = project.getMessageBus(); if (!project.isDefault()) { myConnection = myBus.connect(); final VcsListener vcsListener = new VcsListener() { @Override public void directoryMappingChanged() { myLocationCache.reset(); refreshAllCachesAsync(false, true); refreshIncomingChangesAsync(); myTaskQueue.run(new Runnable() { @Override public void run() { final List<ChangesCacheFile> files = myCachesHolder.getAllCaches(); for (ChangesCacheFile file : files) { final RepositoryLocation location = file.getLocation(); fireChangesLoaded(location, Collections.<CommittedChangeList>emptyList()); } fireIncomingReloaded(); } }); } }; myLocationCache = new RepositoryLocationCache(project); myCachesHolder = new CachesHolder(project, myLocationCache); myTaskQueue = new ProgressManagerQueue(project, VcsBundle.message("committed.changes.refresh.progress")); ((ProjectLevelVcsManagerImpl)vcsManager).addInitializationRequest(VcsInitObject.COMMITTED_CHANGES_CACHE, new Runnable() { @Override public void run() { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { if (myProject.isDisposed()) return; myTaskQueue.start(); myConnection.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, vcsListener); myConnection.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED_IN_PLUGIN, vcsListener); } }); } }); Disposer.register(project, () -> { cancelRefreshTimer(); myConnection.disconnect(); }); myExternallyLoadedChangeLists = ContainerUtil.newConcurrentMap(); } }
Example 9
Source File: FileTree.java From consulo with Apache License 2.0 | 4 votes |
FileTree() { myDirectory2Children = ContainerUtil.newConcurrentMap(); myFiles = ContainerUtil.newConcurrentSet(); myStrictDirectory2Children = ContainerUtil.newConcurrentMap(); }