Search in sources :

Example 1 with FileWatcher

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

LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 FileWatcher (com.intellij.openapi.vfs.impl.local.FileWatcher)1 LocalFileSystemImpl (com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl)1 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)1 SmartList (com.intellij.util.SmartList)1