void (EditorEx editor, Container editorContainer, List<? extends UsageInfo> usages, @NotNull Project project) { List<UsageInfo> validUsages = ContainerUtil.filter(usages, Objects::nonNull); InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(project); PsiDocumentManager.getInstance(project).performLaterWhenAllCommitted(() -> { if (!editor.isDisposed()) { editorContainer.invalidate(); editorContainer.validate(); UsagePreviewPanel.highlight(validUsages, editor, project, false, HighlighterLayer.SELECTION); if (validUsages.size() == 1) { UsageInfo usage = validUsages.get(0); final PsiElement element = usage.getElement(); Segment range = usage.getNavigationRange(); if (element != null && range != null) { if (injectedLanguageManager.getInjectionHost(element) != null) { range = injectedLanguageManager.injectedToHost(element, TextRange.create(range)); } final Document document = editor.getDocument(); final int offset = Math.min(range.getEndOffset() + VIEW_ADDITIONAL_OFFSET, document.getLineEndOffset(document.getLineNumber(range.getEndOffset()))); editor.getScrollingModel().scrollTo(editor.offsetToLogicalPosition(offset), ScrollType.CENTER); return; } } editor.getScrollingModel().scrollTo(editor.offsetToLogicalPosition(0), ScrollType.CENTER_UP); } }); }