Skip to main content

ModuleResolver

Struct ModuleResolver 

Source
pub struct ModuleResolver { /* private fields */ }
Expand description

Resolves and loads modules

Implementations§

Source§

impl ModuleResolver

Source

pub fn new(search_paths: Vec<PathBuf>) -> Self

Create a new resolver with given search paths

Source

pub fn find_module_file( &self, base_dir: &Path, module_path: &[String], ) -> Option<PathBuf>

Find the file for a module path

Source

pub fn extract_exports(program: &Program) -> (HashSet<String>, HashSet<String>)

Extract exports from a parsed program Returns (predicate exports, function exports)

Source

pub fn load_module( &mut self, base_dir: &Path, module_path: &[String], ) -> Result<&LoadedModule, ModuleError>

Load a module from a path

Source

pub fn check_import( &self, module_path: &[String], predicate: &str, ) -> Result<(), ModuleError>

Check if a predicate can be imported from a module

Source

pub fn validate_imports( &self, program: &Program, ) -> Result<(HashMap<String, Vec<String>>, HashMap<String, Vec<String>>), ModuleError>

Validate all imports in a program Returns (predicate imports, function imports) mapped to their source modules

Source

pub fn get_module(&self, module_path: &[String]) -> Option<&LoadedModule>

Get a loaded module by path

Source

pub fn is_loaded(&self, module_path: &str) -> bool

Check if a module is loaded

Source

pub fn loaded_modules(&self) -> Vec<&str>

Get all loaded module paths (for testing)

Source

pub fn merge_imports(&self, program: Program) -> Result<Program, ModuleError>

Merge all imported modules into a program. Returns a new program with all imports resolved and merged.

§Arguments
  • program - The main program with imports to resolve
§Returns

The program with all imports merged in

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,