void (Project project, String insertText, Semaphore typingSemaphore) { SearchEverywhereUI ui = SearchEverywhereManager.getInstance(project).getCurrentlyShownUI(); Span insertSpan = PerformanceTestSpan.TRACER.spanBuilder("searchEverywhere_items_loaded").startSpan(); Span firstBatchAddedSpan = PerformanceTestSpan.TRACER.spanBuilder("searchEverywhere_first_elements_added").startSpan(); ui.addSearchListener(new SearchAdapter(){ @Override public void elementsAdded(@NotNull List<? extends SearchEverywhereFoundElementInfo> list) { super.elementsAdded(list); firstBatchAddedSpan.setAttribute("number", list.size()); firstBatchAddedSpan.end(); } }); //noinspection TestOnlyProblems Future<List<Object>> elements = ui.findElementsForPattern(insertText); ApplicationManager.getApplication().executeOnPooledThread(Context.current().wrap((Callable<Object>)() -> { insertSpan.setAttribute("text", insertText); List<Object> result = elements.get(); insertSpan.setAttribute("number", result.size()); insertSpan.end(); typingSemaphore.release(); return result; })); }