void (UsageInfo @NotNull [] usages) { if (ApplicationManager.getApplication().isUnitTestMode()) { if (!PREVIEW_IN_TESTS) throw new RuntimeException("Unexpected preview in tests: " + StringUtil.join(usages, UsageInfo::toString, ", ")); ensureElementsWritable(usages, createUsageViewDescriptor(usages)); execute(usages); return; } final UsageViewDescriptor viewDescriptor = createUsageViewDescriptor(usages); final PsiElement[] elements = viewDescriptor.getElements(); final PsiElement2UsageTargetAdapter[] targets = PsiElement2UsageTargetAdapter.convert(elements); Factory<UsageSearcher> factory = () -> new UsageInfoSearcherAdapter() { @Override public void generate(@NotNull final Processor<? super Usage> processor) { ApplicationManager.getApplication().runReadAction(() -> { for (int i = 0; i < elements.length; i++) { elements[i] = targets[i].getElement(); } refreshElements(elements); }); processUsages(processor, myProject); } @Override protected UsageInfo @NotNull [] findUsages() { return BaseRefactoringProcessor.this.findUsages(); } }; showUsageView(viewDescriptor, factory, usages); }