Search in sources :

Example 1 with NewVirtualFileSystem

use of com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem in project intellij-community by JetBrains.

the class RefreshWorker method scan.

public void scan() {
    NewVirtualFile root = myRefreshQueue.peekFirst().first;
    NewVirtualFileSystem fs = root.getFileSystem();
    if (root.isDirectory()) {
        fs = PersistentFS.replaceWithNativeFS(fs);
    }
    try {
        processQueue(fs, PersistentFS.getInstance());
    } catch (RefreshCancelledException e) {
        LOG.debug("refresh cancelled");
    }
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) NewVirtualFileSystem(com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem)

Example 2 with NewVirtualFileSystem

use of com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem in project intellij-community by JetBrains.

the class VirtualDirectoryImpl method getChildren.

@Override
@NotNull
public VirtualFile[] getChildren() {
    if (!isValid()) {
        throw new InvalidVirtualFileAccessException(this);
    }
    NewVirtualFileSystem delegate = getFileSystem();
    final boolean ignoreCase = !delegate.isCaseSensitive();
    synchronized (myData) {
        if (allChildrenLoaded()) {
            assertConsistency(ignoreCase, "");
            return getArraySafely();
        }
        final boolean wasChildrenLoaded = ourPersistence.areChildrenLoaded(this);
        final FSRecords.NameId[] childrenIds = ourPersistence.listAll(this);
        int[] result;
        if (childrenIds.length == 0) {
            result = ArrayUtil.EMPTY_INT_ARRAY;
        } else {
            Arrays.sort(childrenIds, (o1, o2) -> {
                CharSequence name1 = o1.name;
                CharSequence name2 = o2.name;
                int cmp = compareNames(name1, name2, ignoreCase);
                if (cmp == 0 && name1 != name2) {
                    LOG.error(ourPersistence + " returned duplicate file names(" + name1 + "," + name2 + ")" + " ignoreCase: " + ignoreCase + " SystemInfo.isFileSystemCaseSensitive: " + SystemInfo.isFileSystemCaseSensitive + " SystemInfo.OS: " + SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION + " wasChildrenLoaded: " + wasChildrenLoaded + " in the dir: " + this + ";" + " children: " + Arrays.toString(childrenIds));
                }
                return cmp;
            });
            TIntHashSet prevChildren = new TIntHashSet(myData.myChildrenIds);
            result = new int[childrenIds.length];
            for (int i = 0; i < childrenIds.length; i++) {
                FSRecords.NameId child = childrenIds[i];
                result[i] = child.id;
                assert child.id > 0 : child;
                prevChildren.remove(child.id);
                if (VfsData.getFileById(child.id, this) == null) {
                    createChild(child.nameId, child.id, delegate);
                }
            }
            if (!prevChildren.isEmpty()) {
                LOG.error("Loaded child disappeared: " + "parent=" + verboseToString.fun(this) + "; child=" + verboseToString.fun(VfsData.getFileById(prevChildren.toArray()[0], this)));
            }
        }
        if (getId() > 0) {
            myData.myChildrenIds = result;
            if (CHECK) {
                assertConsistency(ignoreCase, Arrays.asList(childrenIds));
            }
            setChildrenLoaded();
        }
        return getArraySafely();
    }
}
Also used : FSRecords(com.intellij.openapi.vfs.newvfs.persistent.FSRecords) NewVirtualFileSystem(com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem) InvalidVirtualFileAccessException(com.intellij.openapi.vfs.InvalidVirtualFileAccessException) TIntHashSet(gnu.trove.TIntHashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with NewVirtualFileSystem

use of com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem in project intellij-community by JetBrains.

the class VirtualDirectoryImpl method iterInDbChildren.

@Override
@NotNull
public Iterable<VirtualFile> iterInDbChildren() {
    if (!ourPersistence.wereChildrenAccessed(this)) {
        return Collections.emptyList();
    }
    if (!ourPersistence.areChildrenLoaded(this)) {
        final String[] names = ourPersistence.listPersisted(this);
        final NewVirtualFileSystem delegate = PersistentFS.replaceWithNativeFS(getFileSystem());
        for (String name : names) {
            findChild(name, false, false, delegate);
        }
    }
    return getCachedChildren();
}
Also used : NewVirtualFileSystem(com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NewVirtualFileSystem (com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem)3 NotNull (org.jetbrains.annotations.NotNull)2 InvalidVirtualFileAccessException (com.intellij.openapi.vfs.InvalidVirtualFileAccessException)1 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)1 FSRecords (com.intellij.openapi.vfs.newvfs.persistent.FSRecords)1 TIntHashSet (gnu.trove.TIntHashSet)1