Document analysis and navigation for Lex
This crate provides semantic analysis capabilities for Lex documents, enabling features like reference resolution, symbol extraction, token classification, and document navigation.
Architecture
The crate is organized into several modules:
utils: Core document traversal and lookup utilitiesreferences: Reference resolution and target conversioninline: Inline span detection (bold, italic, code, references)tokens: Semantic token extraction and classificationsymbols: Document structure and symbol hierarchyhover: Preview text extraction for hover tooltipsfolding: Foldable range detectionnavigation: Go-to-definition and find-references
Design Principles
- Stateless: All functions operate on immutable AST references
- Reusable: Not tied to LSP protocol - usable by CLI, editor plugins, etc.
- Well-tested: Comprehensive unit tests using official sample fixtures
- AST-focused: Works directly with lex-parser AST types
Usage
use ;
use parse;
let document = parse?;
// Extract tokens for syntax highlighting
let tokens = extract_semantic_tokens;
// Build document outline
let symbols = extract_document_symbols;
// Resolve references
let defs = find_definition;