1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::services::references as refs;
use crate::shims::to_range;
use crate::ProgramInfo;
use tower_lsp::lsp_types::*;
pub(crate) fn get_semantic_highlights(
position: Position,
program_info: &ProgramInfo,
) -> Option<Vec<DocumentHighlight>> {
let ProgramInfo { source, .. } = program_info;
let references = refs::get_kinded_references(position, program_info)?;
let references = references
.into_iter()
.map(|rk| DocumentHighlight {
range: to_range(rk.span(), source),
kind: Some(match rk {
refs::ReferenceKind::Definition(_) => DocumentHighlightKind::Write,
refs::ReferenceKind::Usage(_) => DocumentHighlightKind::Read,
}),
})
.collect();
Some(references)
}