use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatusResponse {
pub files: usize,
pub symbols: usize,
pub references: usize,
pub calls: usize,
pub code_chunks: usize,
pub db_path: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FindResponse {
pub symbols: Vec<MagellanSymbol>,
pub count: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MagellanSymbol {
#[serde(skip_serializing_if = "Option::is_none")]
pub symbol_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub id_format: Option<String>,
pub name: String,
pub kind: String,
pub file_path: String,
pub byte_start: usize,
pub byte_end: usize,
pub start_line: usize,
pub end_line: usize,
pub start_col: usize,
pub end_col: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RefsResponse {
pub symbol: MagellanSymbol,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub callers: Vec<MagellanCallReference>,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub callees: Vec<MagellanCallReference>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MagellanCallReference {
pub symbol: MagellanSymbol,
pub call_site: MagellanSpan,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MagellanSpan {
pub file_path: String,
pub byte_start: usize,
pub byte_end: usize,
pub start_line: usize,
pub start_col: usize,
pub end_line: usize,
pub end_col: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FilesResponse {
pub files: Vec<MagellanFileMetadata>,
pub count: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MagellanFileMetadata {
pub path: String,
pub hash: String,
pub last_indexed_at: i64,
pub last_modified: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub symbol_count: Option<usize>,
}
impl From<crate::graph::magellan_integration::DatabaseStats> for StatusResponse {
fn from(stats: crate::graph::magellan_integration::DatabaseStats) -> Self {
Self {
files: stats.files,
symbols: stats.symbols,
references: stats.references,
calls: stats.calls,
code_chunks: stats.code_chunks,
db_path: String::new(), }
}
}
impl From<crate::graph::magellan_integration::SymbolInfo> for MagellanSymbol {
fn from(info: crate::graph::magellan_integration::SymbolInfo) -> Self {
let symbol_id = crate::symbol_id::generate_v2(&info.name, &info.file_path, info.byte_start);
Self {
symbol_id: Some(symbol_id.as_str().to_string()),
id_format: Some("v2".to_string()),
name: info.name,
kind: info.kind,
file_path: info.file_path,
byte_start: info.byte_start,
byte_end: info.byte_end,
start_line: 0,
end_line: 0,
start_col: 0,
end_col: 0,
}
}
}
impl From<crate::graph::magellan_integration::CallReference> for MagellanCallReference {
fn from(cr: crate::graph::magellan_integration::CallReference) -> Self {
Self {
symbol: cr.symbol.into(),
call_site: MagellanSpan {
file_path: cr.call_site.file_path,
byte_start: cr.call_site.byte_start,
byte_end: cr.call_site.byte_end,
start_line: cr.call_site.start_line,
start_col: cr.call_site.start_col,
end_line: cr.call_site.end_line,
end_col: cr.call_site.end_col,
},
}
}
}
impl From<crate::graph::magellan_integration::FileMetadata> for MagellanFileMetadata {
fn from(fm: crate::graph::magellan_integration::FileMetadata) -> Self {
Self {
path: fm.path,
hash: fm.hash,
last_indexed_at: fm.last_indexed_at,
last_modified: fm.last_modified,
symbol_count: fm.symbol_count,
}
}
}
impl From<crate::graph::magellan_integration::CallRelationships> for RefsResponse {
fn from(rels: crate::graph::magellan_integration::CallRelationships) -> Self {
Self {
symbol: rels.symbol.into(),
callers: rels.callers.into_iter().map(Into::into).collect(),
callees: rels.callees.into_iter().map(Into::into).collect(),
}
}
}