Function lsp_symbols_to_code_symbols

Source
pub fn lsp_symbols_to_code_symbols(
    document: &Document,
    symbols: &[SemanticDocumentSymbol],
) -> Vec<CodeSymbol>
Expand description

Converts semantic symbols into document-local symbols sourced as LSP.

IDs are assigned from one in input order. Both ranges are numerically clamped to document byte length without UTF-8 boundary repair or ordering; parent and docs are None, and detail becomes the signature. Each input’s own source field is ignored.

§Examples

use ailloli_ui_editor::{code::{lsp_symbols_to_code_symbols, SemanticDocumentSymbol}, Document, DocumentId, SymbolId, SymbolKind, SymbolSource};
use ailloli_ui_text::TextBuffer;
let document = Document::new(DocumentId(1), TextBuffer::from_string("fn x"));
let input = [SemanticDocumentSymbol { name: "x".into(), kind: SymbolKind::Function, range: 0..99, selection_range: 3..4, detail: Some("fn x".into()), source: SymbolSource::Scip }];
let symbols = lsp_symbols_to_code_symbols(&document, &input);
assert_eq!((symbols[0].id, symbols[0].source, symbols[0].range.clone()), (SymbolId(1), SymbolSource::Lsp, 0..4));