Skip to main content

parse_import_layout

Function parse_import_layout 

Source
pub fn parse_import_layout(content: &str) -> ImportLayout
Expand description

Parse the import layout of a Python source file.

Tries AST-based parsing first (via rustpython-parser); falls back to a simpler line-scan if the file has syntax errors (e.g. during active editing).

The returned ImportLayout contains:

  • groups — classified contiguous import blocks with line ranges,
  • from_imports / bare_imports — individual import statements,
  • lines — the file lines (for TextEdit character-length lookups).