@Nullable
  @Override
  public AntBuildFile addBuildFile(final VirtualFile file) throws AntNoFileException {
    final Ref<AntBuildFile> result = Ref.create(null);
    final Ref<AntNoFileException> ex = Ref.create(null);
    final String title = AntBundle.message("dialog.title.register.ant.build.file", file.getPresentableUrl());
    ProgressManager.getInstance().run(new Task.Modal(getProject(), title, false) {
      @NotNull
      @Override
      public NotificationInfo getNotificationInfo() {
        return new NotificationInfo("Ant", AntBundle.message("system.notification.title.ant.task.finished"), "");
      }

      @Override
      public void run(@NotNull final ProgressIndicator indicator) {
        indicator.setIndeterminate(true);
        indicator.pushState();
        try {
          indicator.setText(AntBundle.message("progress.text.register.ant.build.file", file.getPresentableUrl()));
          incModificationCount();
          boolean added = runNonBlocking(() -> {
            try {
              for (AntBuildFile buildFile : getBuildFileList()) {
                final VirtualFile vFile = buildFile.getVirtualFile();
                if (vFile != null && vFile.equals(file)) {
                  result.set(buildFile);
                  return Boolean.FALSE;
                }
              }
              result.set(addBuildFileImpl(file, null));
              updateRegisteredActions();
              return Boolean.TRUE;
            }
            catch (AntNoFileException e) {
              ex.set(e);
            }
            return Boolean.FALSE;
          }, Boolean.FALSE);
          if (added) {
            ApplicationManager.getApplication().invokeLater(() -> myEventDispatcher.getMulticaster().buildFileAdded(result.get()), ModalityState.any());
          }
        }
        catch (ProcessCanceledException ignored) {
        }
        finally {
          indicator.popState();
        }
      }
    });
    if (ex.get() != null) {
      throw ex.get();
    }
    return result.get();
  }
@Nullable
  @Override
  public AntBuildFile addBuildFile(final VirtualFile file)