PersistentFSImpl

This commit is contained in:
Roman Shevchenko
2012-08-07 17:28:11 +04:00
parent 37a5e2587b
commit 089dd6d2d4
10 changed files with 1221 additions and 1146 deletions
@@ -136,7 +136,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
FileDocumentManager.getInstance().saveAllDocuments();
}
});
((PersistentFS)ManagingFS.getInstance()).clearIdCache();
PersistentFS.getInstance().clearIdCache();
for (VirtualFile root : ManagingFS.getInstance().getRoots(this)) {
if (root instanceof VirtualDirectoryImpl) {
@@ -154,7 +154,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
synchronized (this) {
// do not extract getId outside the synchronized block since it will cause a concurrency problem.
int id = PersistentFS.getId(this, name, delegate);
int id = ourPersistence.getId(this, name, delegate);
if (id > 0) {
// maybe another doFindChild() sneaked in the middle
VirtualFileSystemEntry lastTry = map.get(name);
@@ -174,7 +174,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
public VirtualFileSystemEntry createChild(@NotNull String name, int id) {
final VirtualFileSystemEntry child;
final NewVirtualFileSystem fs = getFileSystem();
if (PersistentFS.isDirectory(id)) {
if (ourPersistence.isDirectory(id)) {
child = new VirtualDirectoryImpl(name, this, fs, id);
}
else {
@@ -382,8 +382,8 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
return Arrays.asList(getChildren());
}
final String[] names = PersistentFS.listPersisted(this);
NewVirtualFileSystem delegate = PersistentFS.replaceWithNativeFS(getFileSystem());
final String[] names = ourPersistence.listPersisted(this);
final NewVirtualFileSystem delegate = PersistentFS.replaceWithNativeFS(getFileSystem());
for (String name : names) {
findChild(name, false, false, delegate);
}
@@ -400,7 +400,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
return children;
}
Pair<String[], int[]> pair = PersistentFS.listAll(this);
Pair<String[], int[]> pair = ourPersistence.listAll(this);
final int[] childrenIds = pair.second;
if (childrenIds.length == 0) {
children = EMPTY_ARRAY;
@@ -26,7 +26,6 @@ import com.intellij.openapi.vfs.VfsBundle;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.encoding.EncodingManager;
import com.intellij.openapi.vfs.encoding.EncodingRegistry;
import com.intellij.openapi.vfs.newvfs.ManagingFS;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
import com.intellij.util.io.IOUtil;
@@ -45,7 +44,7 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile {
private static final Key<String> SYMLINK_TARGET = Key.create("SYMLINK_TARGET");
public static final VirtualFileSystemEntry[] EMPTY_ARRAY = new VirtualFileSystemEntry[0];
protected static final PersistentFS ourPersistence = (PersistentFS)ManagingFS.getInstance();
protected static final PersistentFS ourPersistence = PersistentFS.getInstance();
private static final byte DIRTY_FLAG = 0x01;
private static final byte HAS_SYMLINK_FLAG = 0x02;
@@ -20,7 +20,6 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.io.FileAttributes;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.ManagingFS;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem;
import com.intellij.openapi.vfs.newvfs.events.*;
@@ -64,7 +63,7 @@ public class RefreshWorker {
fs = PersistentFS.replaceWithNativeFS(fs);
}
final PersistentFS persistence = (PersistentFS)ManagingFS.getInstance();
final PersistentFS persistence = PersistentFS.getInstance();
while (!myRefreshQueue.isEmpty()) {
final VirtualFileSystemEntry file = (VirtualFileSystemEntry)myRefreshQueue.pullFirst();
@@ -27,7 +27,7 @@
<component>
<interface-class>com.intellij.openapi.vfs.newvfs.ManagingFS</interface-class>
<implementation-class>com.intellij.openapi.vfs.newvfs.persistent.PersistentFS</implementation-class>
<implementation-class>com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl</implementation-class>
</component>
<component>
@@ -28,6 +28,7 @@ import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent;
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl;
import com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl;
import com.intellij.testFramework.PlatformLangTestCase;
import com.intellij.testFramework.PlatformTestUtil;
@@ -209,7 +210,7 @@ public class LocalFileSystemTest extends PlatformLangTestCase {
assertEquals(5, virtualFile.getLength());
FileUtil.writeToFile(file, "new content");
PersistentFS.cleanPersistedContents();
((PersistentFSImpl)PersistentFS.getInstance()).cleanPersistedContents();
s = VfsUtilCore.loadText(virtualFile);
assertEquals("new content", s);
assertEquals(11, virtualFile.getLength());
@@ -76,6 +76,7 @@ import com.intellij.openapi.vfs.encoding.EncodingManager;
import com.intellij.openapi.vfs.encoding.EncodingManagerImpl;
import com.intellij.openapi.vfs.impl.VirtualFilePointerManagerImpl;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl;
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
@@ -185,7 +186,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
}
private static void cleanPersistedVFSContent() {
PersistentFS.cleanPersistedContents();
((PersistentFSImpl)PersistentFS.getInstance()).cleanPersistedContents();
}
public static boolean isLight(Project project) {
@@ -58,6 +58,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl;
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
@@ -157,7 +158,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
}
private static void cleanPersistedVFSContent() {
PersistentFS.cleanPersistedContents();
((PersistentFSImpl)PersistentFS.getInstance()).cleanPersistedContents();
}
@Override