private void schedulePreview(@NotNull Object selectedValue) {
    new Task.Backgroundable(myProject, IdeBundle.message("search.everywhere.preview.showing"), true) {
      @Override
      public void run(@NotNull ProgressIndicator indicator) {
        UsageInfo usageInfo = ReadAction.compute(() -> {
          return findFirstChild();
        });

        List<UsageInfo2UsageAdapter> usages = new ArrayList<>();
        if (usageInfo != null) {
          usages.add(new UsageInfo2UsageAdapter(usageInfo));
        }
        else {
          if (selectedValue instanceof UsageInfo2UsageAdapter) {
            usages.add((UsageInfo2UsageAdapter)selectedValue);
          }
          else if (selectedValue instanceof SearchEverywhereItem) {
            usages.add(((SearchEverywhereItem)selectedValue).getUsage());
          }
        }

        if (myProject != null) {
          UsageAdaptersKt.getUsageInfo(usages, myProject).thenAccept(infos -> {
            List<UsageInfo> usageInfos = !infos.isEmpty() ? infos : null;
            ReadAction.nonBlocking(() -> UsagePreviewPanel.isOneAndOnlyOnePsiFileInUsages(usageInfos))
              .finishOnUiThread(ModalityState.nonModal(), isOneAndOnlyOnePsiFileInUsages -> {
                myUsagePreviewPanel.updateLayout(myProject, usageInfos);
              })
              .coalesceBy(this)
              .submit(AppExecutorUtil.getAppExecutorService());
          }).exceptionally(throwable -> {
            Logger.getInstance(SearchEverywhereUI.class).error(throwable);
            return null;
          });
        }
      }

      @Nullable
      private UsageInfo findFirstChild() {
        if (myProject == null) return null;

        PsiElement psiElement = toPsi(selectedValue);
        if (psiElement == null) return null;

        PsiFile psiFile = psiElement instanceof PsiFile ? (PsiFile)psiElement : null;
        if (psiFile == null) {
          if (psiElement instanceof PsiFileSystemItem pfsi) {
            VirtualFile vFile = pfsi.getVirtualFile();
            PsiFile file = vFile == null ? null : psiElement.getManager().findFile(vFile);
            if (file != null) {
              return new UsageInfo(file, 0, 0, true);
            }
          }
          return new UsageInfo(psiElement);
        }

        StructureViewBuilder structureViewBuilder = LanguageStructureViewBuilder.getInstance().getStructureViewBuilder(psiFile);
        if (!(structureViewBuilder instanceof TreeBasedStructureViewBuilder)) return new UsageInfo(psiElement);

        @NotNull StructureViewModel structureViewModel =
          ((TreeBasedStructureViewBuilder)structureViewBuilder).createStructureViewModel(null);
        myUsagePreviewDisposableList.add(new Disposable() {
          @Override
          public void dispose() {
            Disposer.dispose(structureViewModel);
          }
        });

        TreeElement firstChild = ContainerUtil.getFirstItem(Arrays.stream(structureViewModel.getRoot().getChildren()).toList());
        if (!(firstChild instanceof StructureViewTreeElement)) return new UsageInfo(psiFile);

        Object firstChildElement = ((StructureViewTreeElement)firstChild).getValue();
        if (!(firstChildElement instanceof PsiElement)) return new UsageInfo(psiFile);

        return new UsageInfo((PsiElement)firstChildElement);
      }
    }.queue();
  }
private void schedulePreview(@NotNull Object selectedValue)