private void runAutoMake() {
    Collection<Project> projects = Collections.emptyList();
    final int appIdleTimeout = getAutomakeWhileIdleTimeout(RegistryManager.getInstance());
    if (appIdleTimeout > 0 && ApplicationManager.getApplication().getIdleTime() > appIdleTimeout) {
      // been idle for quite a while, so try to process all open projects while idle
      projects = getOpenProjects();
    }
    else {
      final Project project = getCurrentContextProject();
      if (project != null) {
        projects = Collections.singleton(project);
      }
    }
    if (projects.isEmpty()) {
      return;
    }

    final List<Pair<TaskFuture<?>, AutoMakeMessageHandler>> futures = new SmartList<>();
    for (Project project : projects) {
      if (!canStartAutoMake(project)) {
        continue;
      }

      final List<TargetTypeBuildScope> scopes = CmdlineProtoUtil.createAllModulesScopes(false);
      final AutoMakeMessageHandler handler = new AutoMakeMessageHandler(project);
      final TaskFuture<?> future = scheduleBuild(
        project, false, true, false, scopes, Collections.emptyList(), Collections.singletonMap(BuildParametersKeys.IS_AUTOMAKE, "true"), handler
      );
      myAutomakeFutures.put(future, project);
      futures.add(new Pair<>(future, handler));
    }
    boolean needAdditionalBuild = false;
    for (Pair<TaskFuture<?>, AutoMakeMessageHandler> pair : futures) {
      try {
        pair.first.waitFor();
      }
      catch (Throwable ignored) {
      }
      finally {
        myAutomakeFutures.remove(pair.first);
        if (pair.second.unprocessedFSChangesDetected()) {
          needAdditionalBuild = true;
        }
      }
    }
    if (needAdditionalBuild) {
      scheduleAutoMake();
    }
  }
private void runAutoMake()