Skip to main content

walk_source_with_complexity

Function walk_source_with_complexity 

Source
pub fn walk_source_with_complexity(
    path: &Path,
    source: &str,
) -> (Vec<InventoryEntry>, FxHashMap<String, InventoryComplexity>)
Expand description

Parse source at path once and return every function as an InventoryEntry together with a source_hash -> InventoryComplexity map.

Both the inventory entries and the complexity map come from the SAME parse (including the JSX fallback retry), so the per-function source_hash values line up exactly and a caller can enrich each entry’s metrics by a hash lookup. Functions whose span slice could not be sliced share the empty-input hash and simply don’t pair; that degrades to “no metrics”, never a panic.

Errors are swallowed, matching walk_source: the returned data covers whatever could be parsed.