mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't store duplicates in file watcher output data
This commit is contained in:
@@ -54,9 +54,9 @@ public class FileWatcher {
|
||||
};
|
||||
|
||||
public static class DirtyPaths {
|
||||
public final List<String> dirtyPaths = ContainerUtil.newSmartList();
|
||||
public final List<String> dirtyPathsRecursive = ContainerUtil.newSmartList();
|
||||
public final List<String> dirtyDirectories = ContainerUtil.newSmartList();
|
||||
public final Set<String> dirtyPaths = ContainerUtil.newTroveSet();
|
||||
public final Set<String> dirtyPathsRecursive = ContainerUtil.newTroveSet();
|
||||
public final Set<String> dirtyDirectories = ContainerUtil.newTroveSet();
|
||||
|
||||
public static final DirtyPaths EMPTY = new DirtyPaths();
|
||||
|
||||
@@ -199,22 +199,35 @@ public class FileWatcher {
|
||||
Collection<String> paths = myPathMap.getWatchedPaths(path, true, false);
|
||||
if (!paths.isEmpty()) {
|
||||
synchronized (myLock) {
|
||||
myDirtyPaths.dirtyPaths.addAll(paths);
|
||||
for (String eachPath : paths) {
|
||||
doAddDirtyPath(eachPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyOnAnyEvent();
|
||||
}
|
||||
|
||||
private void doAddDirtyPath(String path) {
|
||||
if (!myDirtyPaths.dirtyPathsRecursive.contains(path)) {
|
||||
myDirtyPaths.dirtyPaths.add(path);
|
||||
}
|
||||
}
|
||||
|
||||
private void doAddDirtyPathRecursive(String path) {
|
||||
myDirtyPaths.dirtyPaths.remove(path);
|
||||
myDirtyPaths.dirtyPathsRecursive.add(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyPathCreatedOrDeleted(@NotNull String path) {
|
||||
Collection<String> paths = myPathMap.getWatchedPaths(path, true, false);
|
||||
if (!paths.isEmpty()) {
|
||||
synchronized (myLock) {
|
||||
for (String p : paths) {
|
||||
myDirtyPaths.dirtyPathsRecursive.add(p);
|
||||
doAddDirtyPathRecursive(p);
|
||||
String parentPath = new File(p).getParent();
|
||||
if (parentPath != null) {
|
||||
myDirtyPaths.dirtyPaths.add(parentPath);
|
||||
doAddDirtyPath(parentPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,7 +251,9 @@ public class FileWatcher {
|
||||
Collection<String> paths = myPathMap.getWatchedPaths(path, false, false);
|
||||
if (!paths.isEmpty()) {
|
||||
synchronized (myLock) {
|
||||
myDirtyPaths.dirtyPathsRecursive.addAll(paths);
|
||||
for (String each : paths) {
|
||||
doAddDirtyPathRecursive(each);
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyOnAnyEvent();
|
||||
|
||||
+3
-3
@@ -271,7 +271,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
}
|
||||
}
|
||||
|
||||
private void markPathsDirty(List<String> dirtyPaths) {
|
||||
private void markPathsDirty(Iterable<String> dirtyPaths) {
|
||||
for (String dirtyPath : dirtyPaths) {
|
||||
VirtualFile file = findFileByPathIfCached(dirtyPath);
|
||||
if (file instanceof NewVirtualFile) {
|
||||
@@ -280,7 +280,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
}
|
||||
}
|
||||
|
||||
private void markFlatDirsDirty(List<String> dirtyPaths) {
|
||||
private void markFlatDirsDirty(Iterable<String> dirtyPaths) {
|
||||
for (String dirtyPath : dirtyPaths) {
|
||||
VirtualFile file = findFileOrParentIfCached(dirtyPath);
|
||||
if (file instanceof NewVirtualFile) {
|
||||
@@ -293,7 +293,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
}
|
||||
}
|
||||
|
||||
private void markRecursiveDirsDirty(List<String> dirtyPaths) {
|
||||
private void markRecursiveDirsDirty(Iterable<String> dirtyPaths) {
|
||||
for (String dirtyPath : dirtyPaths) {
|
||||
VirtualFile file = findFileOrParentIfCached(dirtyPath);
|
||||
if (file instanceof NewVirtualFile) {
|
||||
|
||||
Reference in New Issue
Block a user