void (@Nullable PsiElement element, @Nullable PsiElement toHighlight) { if (element == null || toHighlight == null) { ApplicationManager.getApplication().runWriteAction(() -> myEditor.getDocument().setText("")); return; } ElementModel model = ElementModel.create(element, toHighlight); if (model == null) return; String text = model.myText; ApplicationManager.getApplication().runWriteAction(() -> myEditor.getDocument().setText(text)); EditorHighlighter highlighter = createHighlighter(element); ((EditorEx)myEditor).setHighlighter(highlighter); myEditor.getCaretModel().moveToOffset(model.myHighlightRange.getStartOffset()); myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER); highlightRange(element.getProject(), model.myHighlightRange); }