[lsp] IJPL-189555 Introduce LSP-backed highlight usages (document highlights) feature

Merge-request: IJ-MR-176039
Merged-by: Vladimir Goncharov <vladimir.goncharov@jetbrains.com>

GitOrigin-RevId: 118f6df4d2dd490fc60af2afe6547dc71865a0e5
This commit is contained in:
Vladimir Goncharov
2025-09-25 15:24:42 +00:00
committed by intellij-monorepo-bot
parent cbd3c3b600
commit e228f691bb
@@ -250,7 +250,10 @@ class IdentifierHighlightingComputer(
private fun findTarget(editor: Editor, file: PsiFile, myCaretOffset: Int): PsiElement? {
val offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), myCaretOffset)
return file.findElementAt(offset)
val psiElement = file.findElementAt(offset)
// LSP has an edge case when it tries to highlight a file with no (finegrained) PSI, where the only PSI element is the whole file.
// In this situation we wouldn't want to cache the whole file as an underlying identifier
return if (psiElement != null && psiElement.textRange == file.textRange) null else psiElement
}
/**