private void chooseClassAndImport() {
    CodeInsightUtil.sortIdenticalShortNamedMembers(myTargetClasses, myReference);

    class Maps {
      final Map<PsiClass, String> names;
      final Map<PsiClass, Icon> icons;

      Maps(Map<PsiClass, String> names, Map<PsiClass, Icon> icons) {
        this.names = names;
        this.icons = icons;
      }
    }

    Maps maps = ReadAction.compute(() -> {
      try (AccessToken ignore = SlowOperations.knownIssue("IDEA-346760, EA-1028089")) {
        return new Maps(
          Arrays.stream(myTargetClasses)
            .collect(Collectors.toMap(o -> o, t -> StringUtil.notNullize(t.getQualifiedName()))),
          Arrays.stream(myTargetClasses)
            .collect(Collectors.toMap(o -> o, t -> t.getIcon(0)))
        );
      }
    });

    final BaseListPopupStep<PsiClass> step =
      new BaseListPopupStep<>(QuickFixBundle.message("class.to.import.chooser.title"), myTargetClasses) {

        @Override
        public boolean isAutoSelectionEnabled() {
          return false;
        }

        @Override
        public boolean isSpeedSearchEnabled() {
          return true;
        }

        @Override
        public PopupStep<?> onChosen(PsiClass selectedValue, boolean finalChoice) {
          if (selectedValue == null) {
            return FINAL_CHOICE;
          }

          if (finalChoice) {
            return doFinalStep(() -> {
              PsiDocumentManager.getInstance(myProject).commitAllDocuments();
              addImport(myReference, selectedValue);
            });
          }

          return getExcludesStep(myProject, selectedValue.getQualifiedName());
        }

        @Override
        public boolean hasSubstep(PsiClass selectedValue) {
          return true;
        }

        @Override
        public @NotNull String getTextFor(PsiClass value) {
          return maps.names.getOrDefault(value, "");
        }

        @Override
        public Icon getIconFor(PsiClass value) {
          return maps.icons.get(value);
        }
      };
    JBPopup popup = JBPopupFactory.getInstance().createListPopup(myProject, step, superRenderer -> {
      GroupedItemsListRenderer<Object> baseRenderer = (GroupedItemsListRenderer<Object>)superRenderer;
      ListCellRenderer<Object> psiRenderer = new DefaultPsiElementCellRenderer();
      return (list, value, index, isSelected, cellHasFocus) -> {
        baseRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        JPanel panel = new JPanel(new BorderLayout()) {
          private final AccessibleContext myAccessibleContext = baseRenderer.getAccessibleContext();

          @Override
          public AccessibleContext getAccessibleContext() {
            if (myAccessibleContext == null) {
              return super.getAccessibleContext();
            }
            return myAccessibleContext;
          }
        };
        panel.add(baseRenderer.getNextStepLabel(), BorderLayout.EAST);
        panel.add(psiRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus));
        return panel;
      };
    });

    NavigationUtil.hidePopupIfDumbModeStarts(popup, myProject);
    popup.showInBestPositionFor(myEditor);
  }
private void chooseClassAndImport()