icb_parser/facts.rs
1use icb_common::{Language, NodeKind};
2use serde::{Deserialize, Serialize};
3
4/// A single fact extracted from source code by a language parser.
5///
6/// `RawNode` is a language‑agnostic representation of an AST node. It
7/// captures the kind of the node, its location, an optional name, and
8/// structural relationships through `children`. The `source_file` field
9/// allows the graph builder to filter out external headers when desired.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct RawNode {
12 /// Programming language of the source file.
13 pub language: Language,
14 /// Kind of the node (function, class, call, etc.).
15 pub kind: NodeKind,
16 /// Optional human‑readable name (e.g., function name).
17 pub name: Option<String>,
18 /// Optional unique symbol identifier for cross‑file references.
19 pub usr: Option<String>,
20 /// 1‑based line where this node starts.
21 pub start_line: usize,
22 /// 0‑based column where this node starts.
23 pub start_col: usize,
24 /// 1‑based line where this node ends.
25 pub end_line: usize,
26 /// 0‑based column where this node ends.
27 pub end_col: usize,
28 /// Indices of child `RawNode`s (in the same file) that are directly
29 /// nested under this node according to the AST.
30 pub children: Vec<usize>,
31 /// Path to the source file, if known. Used for filtering system headers.
32 pub source_file: Option<String>,
33}