lex_analysis/lib.rs
1//! Document analysis and navigation for Lex
2//!
3//! This crate provides semantic analysis capabilities for Lex documents,
4//! enabling features like reference resolution, symbol extraction, token
5//! classification, and document navigation.
6//!
7//! # Architecture
8//!
9//! The crate is organized into several modules:
10//!
11//! - `utils`: Core document traversal and lookup utilities
12//! - `references`: Reference resolution and target conversion
13//! - `inline`: Inline span detection (bold, italic, code, references)
14//! - `tokens`: Semantic token extraction and classification
15//! - `symbols`: Document structure and symbol hierarchy
16//! - `hover`: Preview text extraction for hover tooltips
17//! - `folding`: Foldable range detection
18//! - `navigation`: Go-to-definition and find-references
19//!
20//! # Design Principles
21//!
22//! - **Stateless**: All functions operate on immutable AST references
23//! - **Reusable**: Not tied to LSP protocol - usable by CLI, editor plugins, etc.
24//! - **Well-tested**: Comprehensive unit tests using official sample fixtures
25//! - **AST-focused**: Works directly with lex-parser AST types
26//!
27//! # Usage
28//!
29//! ```rust,ignore
30//! use lex_analysis::{tokens, symbols, navigation};
31//! use lex_core::parse;
32//!
33//! let document = parse("1. Introduction\n\nHello world")?;
34//!
35//! // Extract tokens for syntax highlighting
36//! let tokens = tokens::extract_semantic_tokens(&document);
37//!
38//! // Build document outline
39//! let symbols = symbols::extract_document_symbols(&document);
40//!
41//! // Resolve references
42//! let defs = navigation::find_definition(&document, position);
43//! ```
44
45// Core utilities
46pub mod inline;
47pub mod reference_targets;
48pub mod utils;
49
50// Analysis features
51pub mod annotations;
52pub mod completion;
53pub mod diagnostics;
54pub mod document_symbols;
55pub mod folding_ranges;
56pub mod go_to_definition;
57pub mod hover;
58pub mod references;
59pub mod semantic_tokens;
60
61// Test support (available in tests and as dev-dependency)
62#[cfg(any(test, feature = "test-support"))]
63pub mod test_support;