1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4pub struct Symbol {
5 pub symbol_id: String,
6 pub file_id: String,
7 pub path: String,
8 pub language: String,
9 pub name: String,
10 pub kind: String,
11 pub signature: Option<String>,
12 pub doc_comment: Option<String>,
13 pub visibility: Option<String>,
14 pub parent_symbol_id: Option<String>,
15 pub start_line: usize,
16 pub start_column: usize,
17 pub end_line: usize,
18 pub end_column: usize,
19 pub start_byte: usize,
20 pub end_byte: usize,
21 pub body_start_line: Option<usize>,
22 pub body_start_column: Option<usize>,
23 pub body_end_line: Option<usize>,
24 pub body_end_column: Option<usize>,
25 pub body_start_byte: Option<usize>,
26 pub body_end_byte: Option<usize>,
27 pub body_hash: Option<String>,
28 pub semantic_group: Option<String>,
29 pub is_test: bool,
30 pub test_container: bool,
31}
32
33impl Symbol {
34 pub fn hidden_body_line_count(&self) -> Option<usize> {
36 match (self.body_start_line, self.body_end_line) {
37 (Some(start), Some(end)) if end >= start => Some(end - start + 1),
38 _ => None,
39 }
40 }
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
44pub struct FileFact {
45 pub file_id: String,
46 pub path: String,
47 pub language: String,
48 pub content_hash: String,
49 pub content_bytes: i64,
50 pub line_count: Option<i64>,
51 pub indexed_at: String,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
55pub struct ReferenceSite {
56 pub from_symbol_name: String,
57 pub from_symbol_id: String,
58 pub to_symbol_name: String,
59 pub kind: String,
60 pub path: String,
61 pub start_line: Option<usize>,
62 pub start_column: Option<usize>,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
66pub struct StructuralFact {
67 pub structural_fact_id: String,
68 pub path: String,
69 pub language: String,
70 pub pattern_id: String,
71 pub capture_name: String,
72 pub node_kind: String,
73 pub key: Option<String>,
74 pub containing_symbol_name: Option<String>,
75 pub start_line: usize,
76 pub end_line: usize,
77 pub confidence: f64,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
81pub struct LiteralFact {
82 pub literal_id: String,
83 pub path: String,
84 pub literal_text: String,
85 pub kind: String,
86 pub carrier: Option<String>,
87 pub start_line: usize,
88 pub containing_symbol_name: Option<String>,
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
92pub struct TypeFact {
93 pub type_fact_id: String,
94 pub symbol_id: String,
95 pub language: String,
96 pub resolved_type: String,
97 pub generic_params: Option<String>,
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
101pub struct ContextSlice {
102 pub target_symbol: Symbol,
103 pub target_body: String,
104 pub callee_signatures: Vec<String>,
105 pub related_types: Vec<String>,
106 pub related_tests: Vec<Symbol>,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
110pub struct SymbolSearchResult {
111 pub symbol: Symbol,
112 pub score: f64,
113 pub snippet: Option<String>,
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
117pub struct BlastRadiusResult {
118 pub seed_type: String,
119 pub seeds: Vec<String>,
120 pub likely_tests: Vec<TestTarget>,
121 pub impacted_symbols: Vec<ImpactedSymbol>,
122 #[serde(default)]
123 pub traversal_ceiling_reached: bool,
124}
125
126#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
127pub struct TestTarget {
128 pub name: String,
129 pub path: String,
130 pub line: usize,
131 pub reason: String,
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
135pub struct ImpactedSymbol {
136 pub name: String,
137 pub kind: String,
138 pub path: String,
139 pub line: usize,
140 pub depth: usize,
141}