Search in sources :

Example 1 with PersistentFS

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

the class DumpVfsInfoForExcludedFilesAction method dumpChildrenInDbRecursively.

private static void dumpChildrenInDbRecursively(VirtualFile dir, int depth) {
    if (!(dir instanceof NewVirtualFile)) {
        System.out.println(dir.getPresentableUrl() + ": not in db (" + dir.getClass().getName() + ")");
        return;
    }
    List<VirtualFile> dirs = new ArrayList<>();
    int inDb = 0, contentInDb = 0, nullChildren = 0;
    PersistentFS persistentFS = PersistentFS.getInstance();
    if (persistentFS.wereChildrenAccessed(dir)) {
        for (String name : persistentFS.listPersisted(dir)) {
            inDb++;
            NewVirtualFile child = ((NewVirtualFile) dir).refreshAndFindChild(name);
            if (child == null) {
                nullChildren++;
                continue;
            }
            if (child.isDirectory()) {
                dirs.add(child);
            } else if (FSRecords.getContentId(child.getId()) != 0) {
                contentInDb++;
            }
        }
    }
    System.out.print(dir.getPresentableUrl() + ": " + inDb + " children in db");
    if (contentInDb > 0) {
        System.out.print(", content of " + contentInDb + " files in db");
    }
    if (nullChildren > 0) {
        System.out.print(", " + nullChildren + " invalid files in db");
    }
    System.out.println();
    if (depth > 10) {
        System.out.println("too deep, skipping children");
    } else {
        for (VirtualFile childDir : dirs) {
            dumpChildrenInDbRecursively(childDir, depth + 1);
        }
    }
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) PersistentFS(com.intellij.openapi.vfs.newvfs.persistent.PersistentFS)

Example 2 with PersistentFS

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

the class RefResolveServiceImpl method queueUnresolvedFilesSinceLastRestart.

private void queueUnresolvedFilesSinceLastRestart() {
    PersistentFS fs = PersistentFS.getInstance();
    int maxId = FSRecords.getMaxId();
    TIntArrayList list = new TIntArrayList();
    for (int id = fileIsResolved.nextClearBit(1); id >= 0 && id < maxId; id = fileIsResolved.nextClearBit(id + 1)) {
        int nextSetBit = fileIsResolved.nextSetBit(id);
        int endOfRun = Math.min(maxId, nextSetBit == -1 ? maxId : nextSetBit);
        do {
            VirtualFile virtualFile = fs.findFileById(id);
            if (queueIfNeeded(virtualFile, myProject)) {
                list.add(id);
            } else {
                fileIsResolved.set(id);
            }
        } while (++id < endOfRun);
    }
    log("Initially added to resolve " + toVfString(list.toNativeArray()));
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) PersistentFS(com.intellij.openapi.vfs.newvfs.persistent.PersistentFS)

Example 3 with PersistentFS

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

the class FileBasedIndexImpl method processValuesInScope.

private <K, V> boolean processValuesInScope(@NotNull ID<K, V> indexId, @NotNull K dataKey, boolean ensureValueProcessedOnce, @NotNull GlobalSearchScope scope, @Nullable IdFilter idFilter, @NotNull ValueProcessor<V> processor) {
    PersistentFS fs = (PersistentFS) ManagingFS.getInstance();
    IdFilter filter = idFilter != null ? idFilter : projectIndexableFiles(scope.getProject());
    return processValueIterator(indexId, dataKey, null, scope, valueIt -> {
        while (valueIt.hasNext()) {
            final V value = valueIt.next();
            for (final ValueContainer.IntIterator inputIdsIterator = valueIt.getInputIdsIterator(); inputIdsIterator.hasNext(); ) {
                final int id = inputIdsIterator.next();
                if (filter != null && !filter.containsFileId(id))
                    continue;
                VirtualFile file = IndexInfrastructure.findFileByIdIfCached(fs, id);
                if (file != null && scope.accept(file)) {
                    if (!processor.process(file, value)) {
                        return false;
                    }
                    if (ensureValueProcessedOnce) {
                        break;
                    }
                }
            }
        }
        return true;
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) PersistentFS(com.intellij.openapi.vfs.newvfs.persistent.PersistentFS)

Example 4 with PersistentFS

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

the class FileBasedIndexImpl method processVirtualFiles.

private static boolean processVirtualFiles(@NotNull TIntHashSet ids, @NotNull final GlobalSearchScope filter, @NotNull final Processor<VirtualFile> processor) {
    final PersistentFS fs = (PersistentFS) ManagingFS.getInstance();
    return ids.forEach(id -> {
        ProgressManager.checkCanceled();
        VirtualFile file = IndexInfrastructure.findFileByIdIfCached(fs, id);
        if (file != null && filter.accept(file)) {
            return processor.process(file);
        }
        return true;
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) PersistentFS(com.intellij.openapi.vfs.newvfs.persistent.PersistentFS)

Example 5 with PersistentFS

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

the class LoadAllVfsStoredContentsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final ApplicationEx application = ApplicationManagerEx.getApplicationEx();
    String m = "Started loading content";
    LOG.info(m);
    System.out.println(m);
    long start = System.currentTimeMillis();
    count.set(0);
    totalSize.set(0);
    ApplicationManagerEx.getApplicationEx().runProcessWithProgressSynchronously(() -> {
        PersistentFS vfs = (PersistentFS) application.getComponent(ManagingFS.class);
        VirtualFile[] roots = vfs.getRoots();
        for (VirtualFile root : roots) {
            iterateCached(root);
        }
    }, "Loading", false, null);
    long end = System.currentTimeMillis();
    String message = "Finished loading content of " + count + " files. " + "Total size=" + StringUtil.formatFileSize(totalSize.get()) + ". " + "Elapsed=" + ((end - start) / 1000) + "sec.";
    LOG.info(message);
    System.out.println(message);
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) PersistentFS(com.intellij.openapi.vfs.newvfs.persistent.PersistentFS) ManagingFS(com.intellij.openapi.vfs.newvfs.ManagingFS)

Aggregations

NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)5 PersistentFS (com.intellij.openapi.vfs.newvfs.persistent.PersistentFS)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)1 ManagingFS (com.intellij.openapi.vfs.newvfs.ManagingFS)1