pub struct Imports { /* private fields */ }Expand description
A resolved import table built from import statements anywhere in a Module
(recursing into nested function and class bodies for file-wide resolution).
Implementations§
Source§impl Imports
impl Imports
Sourcepub fn build(module: &Module<'_>) -> Self
pub fn build(module: &Module<'_>) -> Self
Build an Imports table from a parsed Module.
Imports are collected file-wide — recursing into function and class
bodies, not just the module’s top-level statements — so a function-local
def f(): import subprocess; … still resolves call-site names. The flat
table is file-scoped (not block-scoped): an import in one function can
resolve a same-named call in another. This over-approximation is acceptable
for a syntactic heuristic (see spec Deferred / Future work).
Sourcepub fn resolve(&self, local: &str) -> Option<&str>
pub fn resolve(&self, local: &str) -> Option<&str>
Resolve a local name to its fully-qualified module path.
Returns None when the name was not introduced by any import statement.
Sourcepub fn has_dynamic(&self) -> bool
pub fn has_dynamic(&self) -> bool
true when importlib or __import__ appears as an imported name,
indicating the file uses dynamic-import infrastructure. Callers may
apply a confidence penalty when resolving import-dependent signals.