void (@NotNull Editor editor, PsiReference @NotNull [] occurrences, @NotNull TextAttributesKey attributesKey, boolean hideByTextChange, @Nullable Collection<? super RangeHighlighter> outHighlighters) { if (occurrences.length == 0) return; int flags = HIDE_BY_ESCAPE; if (hideByTextChange) { flags |= HIDE_BY_TEXT_CHANGE; } int oldOffset = editor.getCaretModel().getOffset(); int horizontalScrollOffset = editor.getScrollingModel().getHorizontalScrollOffset(); int verticalScrollOffset = editor.getScrollingModel().getVerticalScrollOffset(); for (PsiReference occurrence : occurrences) { PsiElement element = occurrence.getElement(); int startOffset = element.getTextRange().getStartOffset(); int start = startOffset + occurrence.getRangeInElement().getStartOffset(); int end = startOffset + occurrence.getRangeInElement().getEndOffset(); PsiFile containingFile = element.getContainingFile(); Project project = element.getProject(); // each reference can reside in its own injected editor Editor textEditor = InjectedLanguageUtil.openEditorFor(containingFile, project); if (textEditor != null) { addOccurrenceHighlight(textEditor, start, end, null, attributesKey, flags, outHighlighters, null); } } editor.getCaretModel().moveToOffset(oldOffset); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); editor.getScrollingModel().scrollHorizontally(horizontalScrollOffset); editor.getScrollingModel().scrollVertically(verticalScrollOffset); }