pub trait ImportSyntax: Sync {
// Required methods
fn parse(&self, source: &str, tree: &Tree) -> ImportBlock;
fn generate_line(&self, req: &ImportRequest<'_>) -> String;
fn classify_group(&self, module_path: &str) -> ImportGroup;
}Expand description
Per-language import engine. One impl per supported language; syntax_for
maps a LangId to its &'static dyn ImportSyntax. This is the single
plug-in point that replaces the scattered match lang dispatch in
parse_imports / generate_import_line_with_namespace / classify_group /
is_supported. Adding a language is a new impl + one registry arm.
The existing engines are thin wrappers over the free functions they already used, so routing through the trait is behavior-preserving (golden-gated).
Required Methods§
Sourcefn parse(&self, source: &str, tree: &Tree) -> ImportBlock
fn parse(&self, source: &str, tree: &Tree) -> ImportBlock
Parse all imports from a file’s already-parsed tree.
Sourcefn generate_line(&self, req: &ImportRequest<'_>) -> String
fn generate_line(&self, req: &ImportRequest<'_>) -> String
Generate a single import line from a structured ImportRequest.
Engines read only the fields they support and ignore the rest.
Sourcefn classify_group(&self, module_path: &str) -> ImportGroup
fn classify_group(&self, module_path: &str) -> ImportGroup
Classify a module path into stdlib / external / internal.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".