pub struct ModuleResolver { /* private fields */ }Expand description
Module resolver for processing file imports
Resolves file imports by loading external modules and inlining them as Module declarations in the AST before transpilation.
Implementations§
Source§impl ModuleResolver
impl ModuleResolver
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new module resolver with default search paths
Default search paths:
.(current directory)./src(source directory)./modules(modules directory)
§Examples
use ruchy::backend::module_resolver::new;
let result = new(());
assert_eq!(result, Ok(()));Sourcepub fn add_search_path<P: AsRef<Path>>(&mut self, path: P)
pub fn add_search_path<P: AsRef<Path>>(&mut self, path: P)
Sourcepub fn resolve_imports(&mut self, ast: Expr) -> Result<Expr>
pub fn resolve_imports(&mut self, ast: Expr) -> Result<Expr>
Resolve all file imports in an AST
Recursively processes the AST to find file imports, loads the corresponding modules, and replaces Import nodes with inline Module nodes.
§Arguments
ast- The AST to process
§Returns
A new AST with all file imports resolved to inline modules
§Errors
Returns an error if:
- Module files cannot be found or loaded
- Module files contain invalid syntax
- Circular dependencies are detected
§Examples
use ruchy::backend::module_resolver::resolve_imports;
let result = resolve_imports(());
assert_eq!(result, Ok(()));Sourcepub fn stats(&self) -> ModuleLoaderStats
pub fn stats(&self) -> ModuleLoaderStats
Get module loading statistics
§Examples
use ruchy::backend::module_resolver::stats;
let result = stats(());
assert_eq!(result, Ok(()));Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the module cache
Forces all modules to be reloaded from disk on next access.
§Examples
use ruchy::backend::module_resolver::clear_cache;
let result = clear_cache(());
assert_eq!(result, Ok(()));Trait Implementations§
Auto Trait Implementations§
impl Freeze for ModuleResolver
impl RefUnwindSafe for ModuleResolver
impl Send for ModuleResolver
impl Sync for ModuleResolver
impl Unpin for ModuleResolver
impl UnwindSafe for ModuleResolver
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
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>
Converts
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>
Converts
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