mod depth;
#[derive(Debug, Clone, PartialEq)]
pub struct NestingAnalysis {
pub max_depth: usize,
pub avg_depth: f64,
pub max_depth_lines: Vec<usize>,
}
impl Default for NestingAnalysis {
fn default() -> Self {
Self {
max_depth: 0,
avg_depth: 0.0,
max_depth_lines: Vec::new(),
}
}
}
pub fn analyze_nesting_depth(content: &str, language: &str) -> NestingAnalysis {
let lang = language.to_lowercase();
let lines: Vec<&str> = content.lines().collect();
if lines.is_empty() {
return NestingAnalysis::default();
}
match lang.as_str() {
"python" | "py" => depth::analyze_indentation_depth(&lines),
_ => depth::analyze_brace_depth(&lines, &lang),
}
}