Search in sources :

Example 1 with LocalFileSystemImpl

use of com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl 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 LocalFileSystemImpl

use of com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl in project intellij-community by JetBrains.

the class PlatformTestCase method cleanupApplicationCaches.

public static void cleanupApplicationCaches(Project project) {
    if (project != null && !project.isDisposed()) {
        UndoManagerImpl globalInstance = (UndoManagerImpl) UndoManager.getGlobalInstance();
        if (globalInstance != null) {
            globalInstance.dropHistoryInTests();
        }
        ((UndoManagerImpl) UndoManager.getInstance(project)).dropHistoryInTests();
        ((DocumentReferenceManagerImpl) DocumentReferenceManager.getInstance()).cleanupForNextTest();
        ((PsiManagerImpl) PsiManager.getInstance(project)).cleanupForNextTest();
    }
    final ProjectManager projectManager = ProjectManager.getInstance();
    assert projectManager != null : "The ProjectManager is not initialized yet";
    ProjectManagerImpl projectManagerImpl = (ProjectManagerImpl) projectManager;
    if (projectManagerImpl.isDefaultProjectInitialized()) {
        Project defaultProject = projectManager.getDefaultProject();
        ((PsiManagerImpl) PsiManager.getInstance(defaultProject)).cleanupForNextTest();
    }
    AsyncHighlighterUpdater.completeAsyncTasks();
    ((FileBasedIndexImpl) FileBasedIndex.getInstance()).cleanupForNextTest();
    LocalFileSystemImpl localFileSystem = (LocalFileSystemImpl) LocalFileSystem.getInstance();
    if (localFileSystem != null) {
        localFileSystem.cleanupForNextTest();
    }
}
Also used : UndoManagerImpl(com.intellij.openapi.command.impl.UndoManagerImpl) Project(com.intellij.openapi.project.Project) DocumentReferenceManagerImpl(com.intellij.openapi.command.impl.DocumentReferenceManagerImpl) PsiManagerImpl(com.intellij.psi.impl.PsiManagerImpl) FileBasedIndexImpl(com.intellij.util.indexing.FileBasedIndexImpl) LocalFileSystemImpl(com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl) ProjectManager(com.intellij.openapi.project.ProjectManager) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl)

Example 3 with LocalFileSystemImpl

use of com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl in project intellij-community by JetBrains.

the class StartupManagerImpl method checkProjectRoots.

private void checkProjectRoots() {
    VirtualFile[] roots = ProjectRootManager.getInstance(myProject).getContentRoots();
    if (roots.length == 0)
        return;
    LocalFileSystem fs = LocalFileSystem.getInstance();
    if (!(fs instanceof LocalFileSystemImpl))
        return;
    FileWatcher watcher = ((LocalFileSystemImpl) fs).getFileWatcher();
    if (!watcher.isOperational())
        return;
    PooledThreadExecutor.INSTANCE.submit(() -> {
        LOG.debug("FW/roots waiting started");
        while (true) {
            if (myProject.isDisposed())
                return;
            if (!watcher.isSettingRoots())
                break;
            TimeoutUtil.sleep(10);
        }
        LOG.debug("FW/roots waiting finished");
        Collection<String> manualWatchRoots = watcher.getManualWatchRoots();
        if (!manualWatchRoots.isEmpty()) {
            List<String> nonWatched = new SmartList<>();
            for (VirtualFile root : roots) {
                if (!(root.getFileSystem() instanceof LocalFileSystem))
                    continue;
                String rootPath = root.getPath();
                for (String manualWatchRoot : manualWatchRoots) {
                    if (FileUtil.isAncestor(manualWatchRoot, rootPath, false)) {
                        nonWatched.add(rootPath);
                    }
                }
            }
            if (!nonWatched.isEmpty()) {
                String message = ApplicationBundle.message("watcher.non.watchable.project");
                watcher.notifyOnFailure(message, null);
                LOG.info("unwatched roots: " + nonWatched);
                LOG.info("manual watches: " + manualWatchRoots);
            }
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) FileWatcher(com.intellij.openapi.vfs.impl.local.FileWatcher) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) LocalFileSystemImpl(com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl) SmartList(com.intellij.util.SmartList)

Aggregations

LocalFileSystemImpl (com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl)3 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 DocumentReferenceManagerImpl (com.intellij.openapi.command.impl.DocumentReferenceManagerImpl)1 UndoManagerImpl (com.intellij.openapi.command.impl.UndoManagerImpl)1 Project (com.intellij.openapi.project.Project)1 ProjectManager (com.intellij.openapi.project.ProjectManager)1 ProjectManagerImpl (com.intellij.openapi.project.impl.ProjectManagerImpl)1 FileWatcher (com.intellij.openapi.vfs.impl.local.FileWatcher)1 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)1 RefreshWorker (com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker)1 PsiManagerImpl (com.intellij.psi.impl.PsiManagerImpl)1 SmartList (com.intellij.util.SmartList)1 FileBasedIndexImpl (com.intellij.util.indexing.FileBasedIndexImpl)1