if (highlighter.getUserData(IN_PREVIEW_USAGE_FLAG) != null) {
markupModel.removeHighlighter(highlighter);
}
}
for (int i = infos.size()-1; i>=0; i--) { // finish with the first usage so that caret end up there
UsageInfo info = infos.get(i);
PsiElement psiElement = info.getElement();
if (psiElement == null || !psiElement.isValid()) continue;
int offsetInFile = psiElement.getTextOffset();
EditorColorsManager colorManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
TextRange elementRange = psiElement.getTextRange();
TextRange infoRange = info.getRange();
TextRange textRange = elementRange.contains(infoRange) ? elementRange.cutOut(infoRange) : elementRange;
// hack to determine element range to highlight
if (psiElement instanceof PsiNamedElement && !(psiElement instanceof PsiFile)) {
PsiFile psiFile = psiElement.getContainingFile();
PsiElement nameElement = psiFile.findElementAt(offsetInFile);