public @NotNull Promise<?> initialize(@NotNull Project project,
                                        final boolean suggestSearchInLibs,
                                        final boolean prevSearchWholeFiles,
                                        @Nullable Object selection,
                                        @Nullable Condition<? super ScopeDescriptor> scopeFilter) {
    if (myProject != null) {
      throw new IllegalStateException("scope chooser combo already initialized");
    }

    LOG.debug("Initializing scope chooser combo");
    scopeModel = project.getService(ScopeService.class)
      .createModel(EnumSet.of(
        ScopeOption.FROM_SELECTION,
        ScopeOption.USAGE_VIEW,
        ScopeOption.LIBRARIES,
        ScopeOption.SEARCH_RESULTS
      ));
    Disposer.register(this, scopeModel);
    for (Map.Entry<ScopeOption, Boolean> entry : postponedOptions.entrySet()) {
      scopeModel.setOption(entry.getKey(), entry.getValue());
    }
    postponedOptions.clear();
    scopeModel.setFilter(descriptor -> myScopeFilter == null || myScopeFilter.value(descriptor));
    scopeModel.addScopeModelListener(new MyScopeModelListener());
    myProject = project;

    NamedScopesHolder.ScopeListener scopeListener = () -> {
      SearchScope selectedScope = getSelectedScope();
      rebuildModelAndSelectScopeOnSuccess(selectedScope);
    };
    myScopeFilter = scopeFilter;
    NamedScopeManager.getInstance(project).addScopeListener(scopeListener, this);
    DependencyValidationManager.getInstance(project).addScopeListener(scopeListener, this);
    addActionListener(this::handleScopeChooserAction);

    ComboBox<ScopeDescriptor> combo = getComboBox();
    combo.setMinimumAndPreferredWidth(JBUIScale.scale(300));
    combo.setRenderer(createRenderer());
    combo.setSwingPopup(false);

    if (selection != null) {
      var provider = PredefinedSearchScopeProvider.getInstance();
      var scopes = provider.getPredefinedScopes(project,
                                                null,
                                                suggestSearchInLibs,
                                                prevSearchWholeFiles,
                                                false,
                                                false,
                                                false);
      for (SearchScope s : scopes) {
        if (selection.equals(s.getDisplayName())) {
          preselectedScope = s;
          break;
        }
      }
    }

    initPromise = new AsyncPromise<>();
    rebuildModelAndSelectScopeOnSuccess(selection);
    return initPromise;
  }
public @NotNull Promise<?> initialize(@NotNull Project project,
                                        final boolean suggestSearchInLibs,
                                        final boolean prevSearchWholeFiles,
                                        @Nullable Object selection,
                                        @Nullable Condition<? super ScopeDescriptor> scopeFilter)