From b5d89d911190983a350b4055e0c53c8ce0f53b8a Mon Sep 17 00:00:00 2001 From: Alexander Kass Date: Mon, 9 Apr 2018 12:08:41 +0300 Subject: [PATCH] DB virtual file is valid while present --- .../vfs/ex/dummy/DummyCachingFileSystem.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/dummy/DummyCachingFileSystem.java b/platform/platform-impl/src/com/intellij/openapi/vfs/ex/dummy/DummyCachingFileSystem.java index b6d721a01dad..be76b832ed1a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/dummy/DummyCachingFileSystem.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/ex/dummy/DummyCachingFileSystem.java @@ -22,18 +22,20 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ProjectManagerListener; import com.intellij.openapi.project.impl.ProjectManagerImpl; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent; -import com.intellij.openapi.vfs.newvfs.events.VFileEvent; import com.intellij.util.containers.ConcurrentFactoryMap; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.Collection; +import java.util.Iterator; +import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentMap; import java.util.stream.Collectors; @@ -147,18 +149,16 @@ public abstract class DummyCachingFileSystem extends Dumm } protected void clearCache() { - clearInvalidFiles(null); + retainFiles(VirtualFile::isValid); } - protected void clearInvalidFiles(@Nullable List events) { + protected void retainFiles(@NotNull Condition c) { Iterator> it = myCachedFiles.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = it.next(); T t = entry.getValue(); - if (t != null && t.isValid()) continue; - it.remove(); - if (events != null && t != null) { - events.add(new VFileDeleteEvent(this, t, false)); + if (t == null || !c.value(t)) { + myCachedFiles.remove(entry.getKey(), entry.getValue()); } } }