private boolean updateList(boolean onExplicitAction, boolean reused) {
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      ThreadingAssertions.assertEventDispatchThread();
    }
    checkValid();

    CollectionListModelWithBatchUpdate<LookupElement> listModel = getListModel();

    Pair<List<LookupElement>, Integer> pair = myPresentableArranger.arrangeItems(this, onExplicitAction || reused);
    List<LookupElement> items = pair.first;
    Integer toSelect = pair.second;
    if (toSelect == null || toSelect < 0 || !items.isEmpty() && toSelect >= items.size()) {
      LOG.error("Arranger " + myPresentableArranger + " returned invalid selection index=" + toSelect + "; items=" + items);
      toSelect = 0;
    }
    if (!myPresentation.getMostRelevantOnTop()) {
      items = ContainerUtil.reverse(items);
      toSelect = Math.max(0, items.size() - toSelect - 1);
    }

    if (!myFirstElementAdded && !items.isEmpty()) {
      myFirstElementAdded = true;
      for (LookupListener listener : myListeners) {
        listener.firstElementShown();
      }
    }

    myOffsets.checkMinPrefixLengthChanges(items, this);
    List<LookupElement> oldModel = listModel.toList();

    List<LookupElement> finalItems = items;
    listModel.performBatchUpdate(model -> {
      synchronized (uiLock) {
        model.removeAll();
        if (!finalItems.isEmpty()) {
          Long currentTimeMillis = System.currentTimeMillis();
          for (LookupElement item : finalItems) {
            item.putUserDataIfAbsent(LOOKUP_ELEMENT_SHOW_TIMESTAMP_MILLIS, currentTimeMillis);
          }
          model.add(finalItems);
          addDummyItems(myDummyItemCount.get());
        }
        else {
          addEmptyItem(model);
        }
      }
    });

    updateListHeight(listModel);

    list.setSelectedIndex(toSelect);
    if (ScreenReader.isActive()) {
      AccessibleContext context = list.getAccessibleContext();
      Accessible child = context.getAccessibleChild(list.getSelectedIndex());
      context.firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, null, child);
    }
    return !ContainerUtil.equalsIdentity(oldModel, items);
  }
private boolean updateList(boolean onExplicitAction, boolean reused)