Skip to main content

analyze_ecmascript

Function analyze_ecmascript 

Source
pub fn analyze_ecmascript(
    workspace: &Path,
    exts: &[&str],
    lang_for_ext: impl Fn(&str) -> Option<Language>,
    candidate_exts_order: &[&str],
    ignore_tests: bool,
) -> Result<Graph>
Expand description

Walk workspace, parse every file whose extension is in exts, and build an [api::Graph] of file + external nodes connected by "uses" edges.

lang_for_ext maps a file extension to a tree-sitter [Language]. Return None to skip the file (the walker already filters by exts; returning None here is an escape hatch for finer control).

candidate_exts_order controls the order in which candidate extensions are tried when resolving an extensionless import specifier, e.g. "./foo". The first match wins. Pass &["ts", "tsx", "js", "jsx"] for TypeScript-first resolution; &["js", "jsx", "mjs", "cjs"] for JS-only projects.