sway_lsp/capabilities/
highlight.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::core::session::Session;
use lsp_types::{DocumentHighlight, Position, Url};
use std::sync::Arc;

pub fn get_highlights(
    session: Arc<Session>,
    url: &Url,
    position: Position,
) -> Option<Vec<DocumentHighlight>> {
    let _p = tracing::trace_span!("get_highlights").entered();
    session.token_ranges(url, position).map(|ranges| {
        ranges
            .into_iter()
            .map(|range| DocumentHighlight { range, kind: None })
            .collect()
    })
}