mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
VirtualFileManagerImpl -> core-impl
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
+8
-11
@@ -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<VirtualFileManagerListener> 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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<VirtualFileListener, VirtualFileListener> myListenerWrappers = new HashMap<VirtualFileListener, VirtualFileListener>();
|
||||
|
||||
public abstract boolean isCaseSensitive();
|
||||
|
||||
+12
@@ -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<VirtualFileSystemEntry> values = myRoots.values();
|
||||
roots = values.toArray(new NewVirtualFile[values.size()]);
|
||||
}
|
||||
|
||||
RefreshQueue.getInstance().refresh(asynchronous, true, postAction, modalityState, roots);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public VirtualFile[] getLocalRoots() {
|
||||
List<NewVirtualFile> roots;
|
||||
|
||||
Reference in New Issue
Block a user