From 900ee038361bdd6945de17d9370de4285833189e Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 19 Aug 2011 17:31:06 +0400 Subject: [PATCH] VirtualFileManagerImpl -> core-impl --- .../vfs/newvfs/CachingVirtualFileSystem.java | 23 ++++++++++++++++ .../vfs/newvfs/FileSystemPersistence.java | 26 +++++++++++++++++++ .../events/VFileContentChangeEvent.java | 0 .../vfs/newvfs/events/VFileCopyEvent.java | 0 .../vfs/newvfs/events/VFileCreateEvent.java | 0 .../vfs/newvfs/events/VFileDeleteEvent.java | 0 .../vfs/newvfs/events/VFileMoveEvent.java | 0 .../openapi/vfs/ex/VirtualFileManagerEx.java | 0 .../impl/BulkVirtualFileListenerAdapter.java | 0 .../vfs/impl/VirtualFileManagerImpl.java | 19 ++++++-------- .../openapi/vfs/newvfs/ManagingFS.java | 2 +- .../vfs/newvfs/NewVirtualFileSystem.java | 2 +- .../vfs/newvfs/persistent/PersistentFS.java | 12 +++++++++ 13 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 platform/core-api/src/com/intellij/openapi/vfs/newvfs/CachingVirtualFileSystem.java create mode 100644 platform/core-api/src/com/intellij/openapi/vfs/newvfs/FileSystemPersistence.java rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/events/VFileContentChangeEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/events/VFileCopyEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/events/VFileDeleteEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/events/VFileMoveEvent.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/vfs/ex/VirtualFileManagerEx.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/vfs/impl/BulkVirtualFileListenerAdapter.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java (93%) diff --git a/platform/core-api/src/com/intellij/openapi/vfs/newvfs/CachingVirtualFileSystem.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/CachingVirtualFileSystem.java new file mode 100644 index 000000000000..6e9173e07e88 --- /dev/null +++ b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/CachingVirtualFileSystem.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.vfs.newvfs; + +/** + * @author yole + */ +public interface CachingVirtualFileSystem { + void refreshWithoutFileWatcher(boolean asynchronous); +} diff --git a/platform/core-api/src/com/intellij/openapi/vfs/newvfs/FileSystemPersistence.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/FileSystemPersistence.java new file mode 100644 index 000000000000..2819ebb27112 --- /dev/null +++ b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/FileSystemPersistence.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.vfs.newvfs; + +import com.intellij.openapi.application.ModalityState; + +/** + * @author yole + */ +public interface FileSystemPersistence { + void refresh(boolean asynchronous, Runnable postAction, ModalityState modalityState); + int getCheapFileSystemModificationCount(); +} diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileContentChangeEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileContentChangeEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileContentChangeEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileContentChangeEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCopyEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCopyEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCopyEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCopyEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileDeleteEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileDeleteEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileDeleteEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileDeleteEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileMoveEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileMoveEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileMoveEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileMoveEvent.java diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/VirtualFileManagerEx.java b/platform/core-impl/src/com/intellij/openapi/vfs/ex/VirtualFileManagerEx.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/vfs/ex/VirtualFileManagerEx.java rename to platform/core-impl/src/com/intellij/openapi/vfs/ex/VirtualFileManagerEx.java diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/BulkVirtualFileListenerAdapter.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/BulkVirtualFileListenerAdapter.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/vfs/impl/BulkVirtualFileListenerAdapter.java rename to platform/core-impl/src/com/intellij/openapi/vfs/impl/BulkVirtualFileListenerAdapter.java diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java similarity index 93% rename from platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java rename to platform/core-impl/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java index 3e80699c2d73..4b35483ed32e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java @@ -24,10 +24,7 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.KeyedExtensionCollector; import com.intellij.openapi.vfs.*; import com.intellij.openapi.vfs.ex.VirtualFileManagerEx; -import com.intellij.openapi.vfs.newvfs.BulkFileListener; -import com.intellij.openapi.vfs.newvfs.ManagingFS; -import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem; -import com.intellij.openapi.vfs.newvfs.RefreshQueue; +import com.intellij.openapi.vfs.newvfs.*; import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; import com.intellij.util.EventDispatcher; import com.intellij.util.containers.ContainerUtil; @@ -57,9 +54,9 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx { private final List myVirtualFileManagerListeners = ContainerUtil.createEmptyCOWList(); private int myRefreshCount = 0; - private final ManagingFS myPersistence; + private final FileSystemPersistence myPersistence; - public VirtualFileManagerImpl(VirtualFileSystem[] fileSystems, MessageBus bus, ManagingFS persistence) { + public VirtualFileManagerImpl(VirtualFileSystem[] fileSystems, MessageBus bus, FileSystemPersistence persistence) { myPersistence = persistence; for (VirtualFileSystem fileSystem : fileSystems) { registerFileSystem(fileSystem); @@ -74,7 +71,7 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx { public void registerFileSystem(VirtualFileSystem fileSystem) { myCollector.addExplicitExtension(fileSystem.getProtocol(), fileSystem); - if (!(fileSystem instanceof NewVirtualFileSystem)) { + if (!(fileSystem instanceof CachingVirtualFileSystem)) { fileSystem.addVirtualFileListener(myVirtualFileListenerMulticaster.getMulticaster()); } myPhysicalFileSystems.add(fileSystem); @@ -105,8 +102,8 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx { } for (VirtualFileSystem fileSystem : getPhysicalFileSystems()) { - if (fileSystem instanceof NewVirtualFileSystem) { - ((NewVirtualFileSystem)fileSystem).refreshWithoutFileWatcher(asynchronous); + if (fileSystem instanceof CachingVirtualFileSystem) { + ((CachingVirtualFileSystem)fileSystem).refreshWithoutFileWatcher(asynchronous); } else { fileSystem.refresh(asynchronous); @@ -123,7 +120,7 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx { ApplicationManager.getApplication().assertIsDispatchThread(); } - RefreshQueue.getInstance().refresh(asynchronous, true, postAction, modalityState, myPersistence.getLocalRoots()); // TODO: Get an idea how to deliver chnages from local FS to jar fs before they go refresh + myPersistence.refresh(asynchronous, postAction, modalityState); //final VirtualFile[] managedRoots = ManagingFS.getInstance().getRoots(); //for (int i = 0; i < managedRoots.length; i++) { @@ -133,7 +130,7 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx { //} for (VirtualFileSystem fileSystem : getPhysicalFileSystems()) { - if (!(fileSystem instanceof NewVirtualFileSystem)) { + if (!(fileSystem instanceof CachingVirtualFileSystem)) { fileSystem.refresh(asynchronous); } } diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/ManagingFS.java b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/ManagingFS.java index c84cb7e9e955..639d9309b607 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/ManagingFS.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/ManagingFS.java @@ -29,7 +29,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.util.List; -public abstract class ManagingFS implements FileSystemInterface { +public abstract class ManagingFS implements FileSystemInterface, FileSystemPersistence { private static class ManagingFSHolder { private static final ManagingFS ourInstance = ApplicationManager.getApplication().getComponent(ManagingFS.class); } diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java index 958001c71769..cfaa0664bab3 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java @@ -31,7 +31,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; -public abstract class NewVirtualFileSystem extends VirtualFileSystem implements FileSystemInterface { +public abstract class NewVirtualFileSystem extends VirtualFileSystem implements FileSystemInterface, CachingVirtualFileSystem { private final Map myListenerWrappers = new HashMap(); public abstract boolean isCaseSensitive(); diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java index 1ba65d511e62..23301ecff9fd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java @@ -20,6 +20,7 @@ package com.intellij.openapi.vfs.newvfs.persistent; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.ex.ApplicationEx; import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.diagnostic.Logger; @@ -726,6 +727,17 @@ public class PersistentFS extends ManagingFS implements ApplicationComponent { RefreshQueue.getInstance().refresh(asynchronous, true, null, roots); } + @Override + public void refresh(boolean asynchronous, Runnable postAction, ModalityState modalityState) { + final NewVirtualFile[] roots; + synchronized (LOCK) { + Collection values = myRoots.values(); + roots = values.toArray(new NewVirtualFile[values.size()]); + } + + RefreshQueue.getInstance().refresh(asynchronous, true, postAction, modalityState, roots); + } + @NotNull public VirtualFile[] getLocalRoots() { List roots;