get_highlights (capabilities/highlight.rs)

sway · sway-lsp/src/capabilities/highlight.rs · rust · Apache-2.0
dev-tools, tag:knn-classified

Returns LSP document highlights for a given position.

// Source: https://github.com/FuelLabs/sway | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
use crate::core::{session, token_map::TokenMap};
use lsp_types::{DocumentHighlight, Position, Url};
use sway_core::Engines;

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

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key