Search in sources :

Example 1 with RefreshWorker

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

the class RefreshSessionImpl method scan.

public void scan() {
    List<VirtualFile> workQueue = myWorkQueue;
    myWorkQueue = new ArrayList<>();
    boolean haveEventsToFire = myFinishRunnable != null || !myEvents.isEmpty();
    if (!workQueue.isEmpty()) {
        LocalFileSystem fs = LocalFileSystem.getInstance();
        if (fs instanceof LocalFileSystemImpl) {
            ((LocalFileSystemImpl) fs).markSuspiciousFilesDirty(workQueue);
        }
        long t = 0;
        if (LOG.isTraceEnabled()) {
            LOG.trace("scanning " + workQueue);
            t = System.currentTimeMillis();
        }
        int count = 0;
        refresh: do {
            if (LOG.isTraceEnabled())
                LOG.trace("try=" + count);
            for (VirtualFile file : workQueue) {
                if (myCancelled)
                    break refresh;
                NewVirtualFile nvf = (NewVirtualFile) file;
                if (!myIsRecursive && !myIsAsync) {
                    // always scan when non-recursive AND synchronous - needed e.g. when refreshing project files on open
                    nvf.markDirty();
                }
                RefreshWorker worker = new RefreshWorker(nvf, myIsRecursive);
                myWorker = worker;
                worker.scan();
                haveEventsToFire |= myEvents.addAll(worker.getEvents());
            }
            count++;
            if (LOG.isTraceEnabled())
                LOG.trace("events=" + myEvents.size());
        } while (!myCancelled && myIsRecursive && count < 3 && workQueue.stream().anyMatch(f -> ((NewVirtualFile) f).isDirty()));
        if (t != 0) {
            t = System.currentTimeMillis() - t;
            LOG.trace((myCancelled ? "cancelled, " : "done, ") + t + " ms, events " + myEvents);
        }
    }
    myWorker = null;
    myHaveEventsToFire = haveEventsToFire;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RefreshWorker(com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) LocalFileSystemImpl(com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl)

Example 2 with RefreshWorker

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

the class RefreshSessionImpl method cancel.

void cancel() {
    myCancelled = true;
    RefreshWorker worker = myWorker;
    if (worker != null) {
        worker.cancel();
    }
}
Also used : RefreshWorker(com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker)

Aggregations

RefreshWorker (com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker)2 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LocalFileSystemImpl (com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl)1