From f5f224c160fa74deec0426fad532fc052b620069 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 31 Mar 2015 12:38:58 +0200 Subject: [PATCH] Cleanup (consumer is enough) --- .../openapi/vfs/newvfs/VfsImplUtil.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java index a46a221bbe58..77825b188d01 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java @@ -23,14 +23,17 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.ZipFileCache; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.*; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VFileProperty; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.impl.ArchiveHandler; import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent; import com.intellij.openapi.vfs.newvfs.events.VFileEvent; import com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent; import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; +import com.intellij.util.Consumer; import com.intellij.util.Function; -import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -206,15 +209,14 @@ public class VfsImplUtil { ourHandlers.put(localPath, record); final String finalRootPath = localPath; - forEachDirectoryComponent(localPath, new Processor() { + forEachDirectoryComponent(localPath, new Consumer() { @Override - public boolean process(String containingDirectoryPath) { + public void consume(String containingDirectoryPath) { Set handlers = ourDominatorsMap.get(containingDirectoryPath); if (handlers == null) { ourDominatorsMap.put(containingDirectoryPath, handlers = ContainerUtil.newTroveSet()); } handlers.add(finalRootPath); - return true; } }); refresh = true; @@ -236,11 +238,11 @@ public class VfsImplUtil { return t; } - private static void forEachDirectoryComponent(String rootPath, Processor processor) { + private static void forEachDirectoryComponent(String rootPath, Consumer consumer) { int index = rootPath.lastIndexOf('/'); while (index > 0) { String containingDirectoryPath = rootPath.substring(0, index); - if (!processor.process(containingDirectoryPath)) return; + consumer.consume(containingDirectoryPath); index = rootPath.lastIndexOf('/', index - 1); } } @@ -301,14 +303,13 @@ public class VfsImplUtil { public static InvalidationState invalidate(@Nullable InvalidationState state, final String path) { Pair handlerPair = ourHandlers.remove(path); if (handlerPair != null) { - forEachDirectoryComponent(path, new Processor() { + forEachDirectoryComponent(path, new Consumer() { @Override - public boolean process(String containingDirectoryPath) { + public void consume(String containingDirectoryPath) { Set handlers = ourDominatorsMap.get(containingDirectoryPath); if (handlers != null && handlers.remove(path) && handlers.size() == 0) { ourDominatorsMap.remove(containingDirectoryPath); } - return true; } });