pub struct ImportMap { /* private fields */ }Expand description
Per-module import mapping
Maps local names (as used in code) to their full symbol paths.
Each module (file) has its own ImportMap built from its use statements.
Implementations§
Source§impl ImportMap
impl ImportMap
Sourcepub fn add_import(
&mut self,
local_name: impl Into<String>,
full_path: SymbolPath,
)
pub fn add_import( &mut self, local_name: impl Into<String>, full_path: SymbolPath, )
Add a direct import
§Arguments
local_name: The name as used in code (e.g., “HashMap”)full_path: The full symbol path (e.g., “std::collections::HashMap”)
Sourcepub fn add_rename(&mut self, alias: impl Into<String>, full_path: SymbolPath)
pub fn add_rename(&mut self, alias: impl Into<String>, full_path: SymbolPath)
Add a renamed import (use X as Y)
§Arguments
alias: The local alias namefull_path: The full symbol path being aliased
Sourcepub fn add_glob(&mut self, module_path: SymbolPath)
pub fn add_glob(&mut self, module_path: SymbolPath)
Sourcepub fn resolve(&self, name: &str) -> Option<&SymbolPath>
pub fn resolve(&self, name: &str) -> Option<&SymbolPath>
Resolve a name to its full path (without glob resolution)
Checks direct imports and renames only.
For glob resolution, use resolve_with_registry.
Sourcepub fn resolve_with_registry(
&self,
name: &str,
registry: &SymbolRegistry,
) -> Option<SymbolId>
pub fn resolve_with_registry( &self, name: &str, registry: &SymbolRegistry, ) -> Option<SymbolId>
Sourcepub fn imports(&self) -> &HashMap<String, SymbolPath>
pub fn imports(&self) -> &HashMap<String, SymbolPath>
Get all direct imports
Sourcepub fn renames(&self) -> &HashMap<String, SymbolPath>
pub fn renames(&self) -> &HashMap<String, SymbolPath>
Get all renamed imports
Sourcepub fn glob_imports(&self) -> &[SymbolPath]
pub fn glob_imports(&self) -> &[SymbolPath]
Get all glob imports
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ImportMap
impl RefUnwindSafe for ImportMap
impl Send for ImportMap
impl Sync for ImportMap
impl Unpin for ImportMap
impl UnsafeUnpin for ImportMap
impl UnwindSafe for ImportMap
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
Mutably borrows from an owned value. Read more