use lean_ctx::core::property_graph::{CodeGraph, DependencyChain, ImpactResult};
const GRAPH_SOURCE_EXTS: &[&str] = &[
"rs", "ts", "tsx", "js", "jsx", "py", "go", "java", "gd", "cs", "kt", "kts",
];
fn open_graph(root: &str) -> Result<CodeGraph, String> {
CodeGraph::open(root).map_err(|e| format!("Failed to open graph: {e}"))
}
fn served_file_node(graph: &CodeGraph, path: &str) -> bool {
graph.get_node_by_path(path).ok().flatten().is_some() && graph.serves_file(path)
}
fn served_impact(graph: &CodeGraph, file: &str, max_depth: usize) -> anyhow::Result<ImpactResult> {
let mut impact = graph.impact_analysis(file, max_depth)?;
impact.affected_files.retain(|f| graph.serves_file(f));
impact.weak_files.retain(|f| graph.serves_file(f));
Ok(impact)
}
fn served_def_files(graph: &CodeGraph, symbol: &str) -> anyhow::Result<Vec<String>> {
let mut files = graph.resolve_symbol_def_files(symbol)?;
files.retain(|f| graph.serves_symbol(f, symbol));
Ok(files)
}
fn served_chain(
graph: &CodeGraph,
from: &str,
to: &str,
) -> anyhow::Result<Option<DependencyChain>> {
let chain = graph.dependency_chain(from, to)?;
Ok(chain.filter(|chain| chain.path.iter().all(|step| graph.serves_file(step))))
}
mod analyze;
mod build;
pub use analyze::*;
#[allow(unused_imports)]
pub(crate) use build::*;