private void waitForFileWatcher(@NotNull Project project) {
    LocalFileSystem fs = LocalFileSystem.getInstance();
    if (!(fs instanceof LocalFileSystemImpl)) return;

    final FileWatcher watcher = ((LocalFileSystemImpl) fs).getFileWatcher();
    if (!watcher.isOperational() || !watcher.isSettingRoots()) return;

    LOG.info("FW/roots waiting started");
    Task.Modal task =
        new Task.Modal(project, ProjectBundle.message("project.load.progress"), true) {
          @Override
          public void run(@NotNull ProgressIndicator indicator) {
            indicator.setIndeterminate(true);
            indicator.setText(ProjectBundle.message("project.load.waiting.watcher"));
            if (indicator instanceof ProgressWindow) {
              ((ProgressWindow) indicator).setCancelButtonText(CommonBundle.message("button.skip"));
            }
            while (watcher.isSettingRoots() && !indicator.isCanceled()) {
              TimeoutUtil.sleep(10);
            }
            LOG.info("FW/roots waiting finished");
          }
        };
    myProgressManager.run(task);
  }
 @NotNull
 private LocalFileSystem.WatchRequest watch(final File watchFile, final boolean recursive) {
   final Ref<LocalFileSystem.WatchRequest> request = Ref.create();
   getEvents(
       "events to add watch " + watchFile,
       new Runnable() {
         @Override
         public void run() {
           request.set(myFileSystem.addRootToWatch(watchFile.getAbsolutePath(), recursive));
         }
       });
   assertFalse(request.isNull());
   assertFalse(myWatcher.isSettingRoots());
   return request.get();
 }