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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use crate::{ArrayBias, order::NodeKind};
use std::collections::HashMap;
use std::sync::Arc;
#[derive(Debug, Default, Clone)]
pub struct JsonTreeArena {
pub nodes: Vec<JsonTreeNode>,
pub children: Vec<usize>,
pub obj_keys: Vec<String>,
// For arrays: original indices of kept children, stored contiguously per
// array node; objects do not use this.
pub arr_indices: Vec<usize>,
pub root_id: usize,
// True when root is a synthetic wrapper object for multi-input ingest.
// Used to trigger fileset-specific rendering (section headers and summary).
pub is_fileset: bool,
// Optional full text lines for arrays (by arena node id) to support
// downstream features like syntax highlighting even after sampling.
pub code_lines: HashMap<usize, Arc<Vec<String>>>,
}
#[derive(Debug, Clone)]
pub struct JsonTreeNode {
pub kind: NodeKind,
// For atomic leaves (null/bool/number), the exact token text.
pub atomic_token: Option<String>,
pub string_value: Option<String>,
pub children_start: usize,
pub children_len: usize,
pub obj_keys_start: usize,
pub obj_keys_len: usize,
pub array_len: Option<usize>,
pub object_len: Option<usize>,
// For arrays: slice into arena.arr_indices capturing original indices of
// the kept children for this array node.
pub arr_indices_start: usize,
pub arr_indices_len: usize,
pub array_bias_override: Option<ArrayBias>,
pub prefers_parent_line: bool,
// For filesets: marks entries that should render headers only (empty body).
pub fileset_suppressed: bool,
// True for the synthetic root array node wrapping JSONL lines.
pub is_jsonl_root: bool,
}
impl Default for JsonTreeNode {
fn default() -> Self {
Self {
kind: NodeKind::Null,
atomic_token: None,
string_value: None,
children_start: 0,
children_len: 0,
obj_keys_start: 0,
obj_keys_len: 0,
array_len: None,
object_len: None,
arr_indices_start: 0,
arr_indices_len: 0,
array_bias_override: None,
prefers_parent_line: false,
fileset_suppressed: false,
is_jsonl_root: false,
}
}
}