private void reset() { List<String> urls = new ArrayList<String>(); VirtualFile[] localRoots = myManagingFS.getLocalRoots(); for (VirtualFile root : localRoots) { urls.add(root.getPresentableUrl()); } myNotificationSink.notifyPathsRecursive(urls); notifyOnAnyEvent(); }
private void processRemap() { Set<Pair<String, String>> pairs = newHashSet(); for (int i = 0; i < myLines.size() - 1; i += 2) { String pathA = preparePathForMapping(myLines.get(i)); String pathB = preparePathForMapping(myLines.get(i + 1)); pairs.add(Pair.create(pathA, pathB)); } myMapping = newArrayList(pairs); notifyOnAnyEvent(); }
private void processChange(String path, WatcherOp op) { if (SystemInfo.isWindows && op == WatcherOp.RECDIRTY && path.length() == 3 && Character.isLetter(path.charAt(0))) { VirtualFile root = LocalFileSystem.getInstance().findFileByPath(path); if (root != null) { myNotificationSink.notifyPathsRecursive(list(root.getPresentableUrl())); } notifyOnAnyEvent(); return; } if (op == WatcherOp.CHANGE) { // collapse subsequent change file change notifications that happen once we copy large file, // this allows reduction of path checks at least 20% for Windows synchronized (myLock) { for (int i = 0; i < myLastChangedPaths.length; ++i) { int last = myLastChangedPathIndex - i - 1; if (last < 0) last += myLastChangedPaths.length; String lastChangedPath = myLastChangedPaths[last]; if (lastChangedPath != null && lastChangedPath.equals(path)) { return; } } myLastChangedPaths[myLastChangedPathIndex++] = path; if (myLastChangedPathIndex == myLastChangedPaths.length) myLastChangedPathIndex = 0; } } int length = path.length(); if (length > 1 && path.charAt(length - 1) == '/') path = path.substring(0, length - 1); boolean exactPath = op != WatcherOp.DIRTY && op != WatcherOp.RECDIRTY; Collection<String> paths = checkWatchable(path, exactPath, false); if (paths.isEmpty()) { if (LOG.isDebugEnabled()) { LOG.debug("Not watchable, filtered: " + path); } return; } switch (op) { case STATS: case CHANGE: myNotificationSink.notifyDirtyPaths(paths); break; case CREATE: case DELETE: myNotificationSink.notifyPathsCreatedOrDeleted(paths); break; case DIRTY: myNotificationSink.notifyDirtyDirectories(paths); break; case RECDIRTY: myNotificationSink.notifyPathsRecursive(paths); break; default: LOG.error("Unexpected op: " + op); } notifyOnAnyEvent(); }
private void processUnwatchable() { myManualWatchRoots = Collections.unmodifiableList(newArrayList(myLines)); notifyOnAnyEvent(); }