pub enum ImportForm {
Es {
default_import: Option<String>,
namespace_import: Option<String>,
named: Vec<String>,
type_only: bool,
side_effect: bool,
},
Python {
from_import: bool,
named: Vec<String>,
},
RustUse {
visibility: Option<String>,
named: Vec<String>,
},
Go {
alias: Option<String>,
},
Solidity {
named: Vec<String>,
namespace: Option<String>,
alias: Option<String>,
},
Structured {
named: Vec<String>,
namespace: Option<String>,
alias: Option<String>,
modifiers: Vec<String>,
import_kind: Option<String>,
},
}Expand description
Structured, language-honest representation of a single import’s shape.
This is the migration target that replaces the TS-shaped flat fields
(names/default_import/namespace_import) and their per-language
overloads (Rust packs "pub" into default_import; Go packs the alias
there). It is introduced additively alongside the flat fields (Stream M of
the imports-refactor plan): parsers populate BOTH, readers migrate onto
form one at a time behind the golden-parity gate, and the flat fields are
removed once no reader depends on them. New-language variants (Static,
Include, RuntimeRequire, …) are added when their engines land — only the
variants the existing engines produce exist today.
Variants§
Es
ES modules: TypeScript, TSX, JavaScript.
named holds verbatim specifiers ("useState", "stdin as input",
"type Foo", "type Foo as Bar") — see specifier_imported_name.
Fields
Python
Python import module (from_import = false) or
from module import a, b (from_import = true).
RustUse
Rust use path; / pub use path;. visibility replaces the
default_import == "pub" overload (Some("pub"), Some("pub(crate)"),
…). The brace/use-tree text remains carried by module_path per the
lossless-round-trip decision; named holds extracted use-list names.
Go
Go import. alias replaces the default_import overload, including the
blank (_) and dot (.) import bindings.
Solidity
Solidity import, in one of four forms:
- side-effect:
import "x";(all empty) - named:
import { A, B as C } from "x";(named) - namespace:
import * as A from "x";(namespace) - whole-file alias:
import "x" as A;(alias)
named holds verbatim specifiers ("A", "B as C") like the ES form,
so specifier_imported_name / specifier_local_name apply.
Structured
Generic structured form shared by the Phase-1 engines (Java, C#, PHP,
Kotlin, Scala, Swift, …). Carries the full schema field set so a new
engine does not need its own enum variant; module_path (on the parent
ImportStatement) holds the path/FQN. named uses the verbatim
specifier convention.
Trait Implementations§
Source§impl Clone for ImportForm
impl Clone for ImportForm
Source§fn clone(&self) -> ImportForm
fn clone(&self) -> ImportForm
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImportForm
impl Debug for ImportForm
impl Eq for ImportForm
Source§impl PartialEq for ImportForm
impl PartialEq for ImportForm
Source§fn eq(&self, other: &ImportForm) -> bool
fn eq(&self, other: &ImportForm) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ImportForm
Auto Trait Implementations§
impl Freeze for ImportForm
impl RefUnwindSafe for ImportForm
impl Send for ImportForm
impl Sync for ImportForm
impl Unpin for ImportForm
impl UnsafeUnpin for ImportForm
impl UnwindSafe for ImportForm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more