1pub mod chunker;
6pub mod summary;
7pub mod treesitter;
8
9use std::ops::Range;
10use std::path::PathBuf;
11
12#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
14pub enum ChunkKind {
15 Function,
16 Method,
17 Class,
18 Struct,
19 Enum,
20 Interface,
21 Module,
22 Block,
24}
25
26#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
28pub struct CodeChunk {
29 pub id: u64,
31
32 pub file_path: PathBuf,
34
35 pub language: String,
37
38 pub kind: ChunkKind,
40
41 pub name: Option<String>,
43
44 pub signature: Option<String>,
46
47 pub doc_comment: Option<String>,
49
50 pub body: String,
52
53 pub byte_range: Range<usize>,
55
56 pub line_range: Range<usize>,
58}
59
60#[derive(Debug)]
62pub struct ParseResult {
63 pub chunks: Vec<CodeChunk>,
65
66 pub language: String,
68}
69
70impl std::fmt::Display for ChunkKind {
71 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
72 match self {
73 ChunkKind::Function => write!(f, "function"),
74 ChunkKind::Method => write!(f, "method"),
75 ChunkKind::Class => write!(f, "class"),
76 ChunkKind::Struct => write!(f, "struct"),
77 ChunkKind::Enum => write!(f, "enum"),
78 ChunkKind::Interface => write!(f, "interface"),
79 ChunkKind::Module => write!(f, "module"),
80 ChunkKind::Block => write!(f, "block"),
81 }
82 }
83}