lsp-max 26.7.3

Law-state LSP runtime: max LSP 3.18 coverage, process-mining conformance, receipt-chain admission
Documentation
//! Definition lookup implementations.

use crate::jsonrpc::{Error, Result};
use lsp_types_max::{GotoDefinitionParams, GotoDefinitionResponse};
use url::Url;

/// Asks the server for the definition location of a symbol.
pub async fn goto_definition(
    params: GotoDefinitionParams,
) -> Result<Option<GotoDefinitionResponse>> {
    let uri = &params.text_document_position_params.text_document.uri;
    let pos = params.text_document_position_params.position;
    let views = crate::runtime::control_plane::views::get_views();
    let url = Url::parse(uri.as_str()).map_err(|_| Error::internal_error())?;
    if let Some(loc) = crate::runtime::control_plane::views::lookup_definition(views, &url, pos) {
        Ok(Some(GotoDefinitionResponse::Scalar(loc)))
    } else {
        Ok(None)
    }
}