use std::path::PathBuf;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RawScope {
pub local_id: usize,
pub parent_local_id: Option<usize>,
pub scope_kind: String,
pub start_byte: usize,
pub end_byte: usize,
pub start_line: u32,
pub end_line: u32,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RawSymbol {
pub scope_local_id: Option<usize>,
pub name: String,
pub qualified_name: String,
pub kind: String,
pub visibility: String,
pub signature: String,
pub docstring: Option<String>,
pub start_byte: usize,
pub end_byte: usize,
pub start_line: u32,
pub end_line: u32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Via {
Exact,
#[default]
Name,
Macro,
}
impl Via {
pub fn parse(text: &str) -> Via {
match text {
"exact" => Via::Exact,
"macro" => Via::Macro,
_ => Via::Name,
}
}
pub fn as_str(self) -> &'static str {
match self {
Via::Exact => "exact",
Via::Name => "name",
Via::Macro => "macro",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RawSymbolReference {
pub target_symbol_name: String,
pub role: String,
pub start_byte: usize,
pub end_byte: usize,
pub line_number: u32,
pub via: Via,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RawCodeGraphEdge {
pub source_symbol_name: String,
pub target_symbol_name: String,
pub edge_type: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedFilePayload {
pub relative_path: PathBuf,
pub content_hash: String,
pub language: String,
pub line_count: u32,
pub byte_size: usize,
pub scopes: Vec<RawScope>,
pub symbols: Vec<RawSymbol>,
pub references: Vec<RawSymbolReference>,
pub edges: Vec<RawCodeGraphEdge>,
pub syntax_errors: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RawTypeContract {
pub found: bool,
pub type_name: String,
pub kind: Option<String>,
pub signature: Option<String>,
pub docstring: Option<String>,
pub file_path: Option<String>,
pub members: Vec<String>,
}