Skip to main content

extract

Function extract 

Source
pub fn extract(
    unit: &FnUnit<'_>,
    imports: &Imports,
    span: &SpanIndex<'_>,
    referencing_module: &[String],
    referencing_is_package: bool,
    module_map: &PyModuleMap,
) -> Vec<CallSiteRef>
Expand description

Extract all outgoing call references from unit’s own body.

For each call node encountered:

  • base = render_expr(&call.func) (e.g. "os.getcwd", "self.method", "foo"). Calls where render_expr returns None are skipped.
  • root = base.split('.').next() ; module = imports.resolve(root).
  • qualified = module.is_some() — the Python rule.
  • kind = RefKind::Method if base.contains('.') AND module.is_none() (a receiver attribute/method like self.foo/x.bar); else RefKind::Free.
  • line/col from the leftmost_name anchor via the span.
  • resolved_target via the unified expand-split-resolve rule (see brief §5.3): Step A: expand base to a full dotted path using imports.resolve(root), distinguishing the import a.b.c form (R is a segment-boundary prefix of base → use base as-is) from the from m import n form (R is not a prefix → replace root with R, keep trailing members). Step B: split full into target_module + name. Step C: resolve target_module via the map (relative if imports.relative_level(root) is Some, else absolute) and emit [..key, name] on a hit; else None.