public static <T> UsageView showInUsageView(@Nullable PsiElement sourceElement,
                                              T @NotNull [] targets,
                                              @NotNull Function<? super T, ? extends Usage> usageConverter,
                                              @NlsContexts.TabTitle @NotNull String title,
                                              @Nullable Consumer<? super UsageViewPresentation> presentationSetup,
                                              @NotNull Project project) {
    if (targets.length == 0) return null;
    final UsageViewPresentation presentation = new UsageViewPresentation();
    presentation.setCodeUsagesString(title);
    presentation.setTabName(title);
    presentation.setTabText(title);
    if (presentationSetup != null) {
      presentationSetup.consume(presentation);
    }
    UsageTarget[] usageTargets = sourceElement == null ? UsageTarget.EMPTY_ARRAY : new UsageTarget[]{new PsiElement2UsageTargetAdapter(sourceElement)};

    UsageView view = UsageViewManager.getInstance(project).showUsages(usageTargets, Usage.EMPTY_ARRAY, presentation);

    ProgressManager.getInstance().run(new Task.Backgroundable(project, FindBundle.message("progress.title.updating.usage.view")) {
      @Override
      public void run(@NotNull ProgressIndicator indicator) {
        UsageViewImpl impl = (view instanceof UsageViewImpl) ? (UsageViewImpl)view : null;
        for (T pointer : targets) {
          if (impl != null && impl.isDisposed()) break;
          ApplicationManager.getApplication().runReadAction(() -> {
            Usage usage = usageConverter.fun(pointer);
            if (usage != null) {
              view.appendUsage(usage);
            }
          });
        }
        UIUtil.invokeLaterIfNeeded(() -> {
          if (impl != null && !impl.isDisposed()) impl.expandRoot();
        });
      }
    });
    return view;
  }
public static <T> UsageView showInUsageView(@Nullable PsiElement sourceElement,
                                              T @NotNull [] targets,
                                              @NotNull Function<? super T, ? extends Usage> usageConverter,
                                              @NlsContexts.TabTitle @NotNull String title,
                                              @Nullable Consumer<? super UsageViewPresentation> presentationSetup,
                                              @NotNull Project project)