MCPcopy Create free account
hub / github.com/Houseofmvps/codesight / extract_imports

Function extract_imports

plugins/ast/python/src/lib.rs:325–356  ·  view source on GitHub ↗
(body: &[Statement])

Source from the content-addressed store, hash-verified

323// ─── imports ───
324
325fn extract_imports(body: &[Statement]) -> Vec<String> {
326 let mut imports = Vec::new();
327
328 for statement in body {
329 match statement {
330 Statement::Import(import) => {
331 for alias in &import.names {
332 imports.push(alias.name.to_string());
333 }
334 }
335
336 Statement::ImportFrom(import) => {
337 let module = import
338 .module
339 .as_ref()
340 .map(ToString::to_string)
341 .unwrap_or_default();
342
343 for alias in &import.names {
344 if module.is_empty() {
345 imports.push(alias.name.to_string());
346 } else {
347 imports.push(format!("{}.{}", module, alias.name));
348 }
349 }
350 }
351 _ => {}
352 }
353 }
354
355 imports
356}
357
358// ─── schemas ───
359

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected