private void updateWatchedRoots() { Set<String> pathsToRemove = new HashSet<String>(myWatchedOutputs.keySet()); Set<String> toAdd = new HashSet<String>(); for (Artifact artifact : getArtifacts()) { final String path = artifact.getOutputPath(); if (path != null && path.length() > 0) { pathsToRemove.remove(path); if (!myWatchedOutputs.containsKey(path)) { toAdd.add(path); } } } List<LocalFileSystem.WatchRequest> requestsToRemove = new ArrayList<LocalFileSystem.WatchRequest>(); for (String path : pathsToRemove) { final LocalFileSystem.WatchRequest request = myWatchedOutputs.remove(path); ContainerUtil.addIfNotNull(request, requestsToRemove); } Set<LocalFileSystem.WatchRequest> newRequests = LocalFileSystem.getInstance().replaceWatchedRoots(requestsToRemove, toAdd, null); for (LocalFileSystem.WatchRequest request : newRequests) { myWatchedOutputs.put(request.getRootPath(), request); } }
@Override public void disposeComponent() { LocalFileSystem.getInstance().removeWatchedRoots(myWatchedOutputs.values()); }