@NotNull
  @TestOnly
  public List<Object> calcPopupElements(@NotNull String text, boolean checkboxState) {
    List<Object> elements = new SmartList<>("empty");
    Semaphore semaphore = new Semaphore(1);
    scheduleCalcElements(text, checkboxState, ModalityState.nonModal(), SelectMostRelevant.INSTANCE, set -> {
      elements.clear();
      elements.addAll(set);
      semaphore.up();
    });
    long start = System.currentTimeMillis();
    while (!semaphore.waitFor(10) && System.currentTimeMillis() - start < 20_000) {
      UIUtil.dispatchAllInvocationEvents();
    }
    if (!semaphore.waitFor(10)) {
      PerformanceWatcher.dumpThreadsToConsole("Thread dump:");
      throw new UncheckedTimeoutException("Too long background calculation");
    }
    return elements;
  }
@NotNull
  @TestOnly
  public List<Object> calcPopupElements(@NotNull String text, boolean checkboxState)