1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Source file tracking and span management.
//!
//! This module provides the foundation for error reporting with precise
//! source locations. It's used by the raw AST phase to track where every
//! parsed value came from.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────────┐
//! │ SourceRegistry │
//! │ ├── SourceFile 0 (main.nika.yaml) │
//! │ │ ├── content: "schema: ..." │
//! │ │ └── line_starts: [0, 29, 44, ...] │
//! │ ├── SourceFile 1 (included.nika.yaml) │
//! │ └── ... │
//! └─────────────────────────────────────────────────────────────────────┘
//!
//! Span { file: FileId(0), start: 29, end: 44 }
//! → "workflow: test"
//! → workflow.yaml:2:1
//! ```
//!
//! # Example
//!
//! ```
//! use nika_core::source::{SourceRegistry, Span, FileId, Spanned};
//!
//! let mut registry = SourceRegistry::new();
//! let file_id = registry.add_file("workflow.yaml", "schema: \"nika/workflow@0.12\"\nworkflow: test".to_string());
//!
//! // Create a span pointing to "workflow"
//! let span = Span::new(file_id, 29, 37);
//!
//! // Get location string
//! assert_eq!(registry.format_location(span), "workflow.yaml:2:1");
//!
//! // Get text at span
//! assert_eq!(registry.text_at(span), "workflow");
//! ```
pub use ;
pub use ;