pub struct ModuleCache { /* private fields */ }Expand description
Module cache for tracking and resolving imports
Implementations§
Source§impl ModuleCache
impl ModuleCache
Sourcepub fn resolve_import(
&self,
import_path: &str,
current_file: &Path,
workspace_root: Option<&Path>,
) -> Option<PathBuf>
pub fn resolve_import( &self, import_path: &str, current_file: &Path, workspace_root: Option<&Path>, ) -> Option<PathBuf>
Resolve an import path to an absolute file path using runtime module resolution.
Sourcepub fn load_module(&self, path: &Path) -> Option<ModuleInfo>
pub fn load_module(&self, path: &Path) -> Option<ModuleInfo>
Load a module from a file path
If the module is already cached, returns the cached version. Otherwise, reads and parses the file, extracts exports, and caches it.
Sourcepub fn load_module_with_context(
&self,
path: &Path,
current_file: &Path,
workspace_root: Option<&Path>,
) -> Option<ModuleInfo>
pub fn load_module_with_context( &self, path: &Path, current_file: &Path, workspace_root: Option<&Path>, ) -> Option<ModuleInfo>
Context-aware module load using the same module-loader setup as import resolution.
Sourcepub fn load_module_by_import_with_context_and_source(
&self,
import_path: &str,
current_file: &Path,
workspace_root: Option<&Path>,
current_source: Option<&str>,
) -> Option<ModuleInfo>
pub fn load_module_by_import_with_context_and_source( &self, import_path: &str, current_file: &Path, workspace_root: Option<&Path>, current_source: Option<&str>, ) -> Option<ModuleInfo>
Load a module by import path using unified module-loader context.
This supports both filesystem modules and in-memory extension artifacts.
Sourcepub fn get_module(&self, path: &Path) -> Option<ModuleInfo>
pub fn get_module(&self, path: &Path) -> Option<ModuleInfo>
Get a cached module (without loading if not present)
Sourcepub fn invalidate(&self, path: &Path)
pub fn invalidate(&self, path: &Path)
Invalidate a module in the cache (when file changes)
Sourcepub fn list_importable_modules_with_context(
&self,
current_file: &Path,
workspace_root: Option<&Path>,
) -> Vec<String>
pub fn list_importable_modules_with_context( &self, current_file: &Path, workspace_root: Option<&Path>, ) -> Vec<String>
List importable module paths for the current workspace context.
Includes:
std.*modules from stdlib- project module search paths from
shape.toml([modules].paths) - path dependencies from
shape.toml([dependencies])
Sourcepub fn list_importable_modules_with_context_and_source(
&self,
current_file: &Path,
workspace_root: Option<&Path>,
current_source: Option<&str>,
) -> Vec<String>
pub fn list_importable_modules_with_context_and_source( &self, current_file: &Path, workspace_root: Option<&Path>, current_source: Option<&str>, ) -> Vec<String>
List importable module paths with optional current source for frontmatter-aware context.
Sourcepub fn list_importable_modules(&self) -> Vec<String>
pub fn list_importable_modules(&self) -> Vec<String>
List importable module paths using the process CWD as context.
Sourcepub fn list_stdlib_modules(&self) -> Vec<String>
pub fn list_stdlib_modules(&self) -> Vec<String>
List all stdlib module import paths (e.g., std::core::math).
Sourcepub fn list_stdlib_children(&self, prefix: &str) -> Vec<ModuleChild>
pub fn list_stdlib_children(&self, prefix: &str) -> Vec<ModuleChild>
Return direct children under a stdlib prefix for hierarchical completion.
For example, with prefix std::core it can return entries like:
math(leaf, no children)indicators(non-leaf)
Sourcepub fn list_module_children_with_context(
&self,
prefix: &str,
current_file: &Path,
workspace_root: Option<&Path>,
) -> Vec<ModuleChild>
pub fn list_module_children_with_context( &self, prefix: &str, current_file: &Path, workspace_root: Option<&Path>, ) -> Vec<ModuleChild>
Return direct children under an import prefix for hierarchical completion.
Sourcepub fn list_module_children(&self, prefix: &str) -> Vec<ModuleChild>
pub fn list_module_children(&self, prefix: &str) -> Vec<ModuleChild>
Return direct children under an import prefix using process CWD as context.
Sourcepub fn find_exported_symbol_with_context(
&self,
name: &str,
current_file: &Path,
workspace_root: Option<&Path>,
) -> Vec<(String, ExportedSymbol)>
pub fn find_exported_symbol_with_context( &self, name: &str, current_file: &Path, workspace_root: Option<&Path>, ) -> Vec<(String, ExportedSymbol)>
Find all modules that export a symbol with the given name. Scans importable modules and returns (import_path, ExportedSymbol) pairs.
Sourcepub fn find_exported_symbol(&self, name: &str) -> Vec<(String, ExportedSymbol)>
pub fn find_exported_symbol(&self, name: &str) -> Vec<(String, ExportedSymbol)>
Scans importable modules using process CWD as context.
Trait Implementations§
Source§impl Debug for ModuleCache
impl Debug for ModuleCache
Source§impl Default for ModuleCache
impl Default for ModuleCache
Source§fn default() -> ModuleCache
fn default() -> ModuleCache
Auto Trait Implementations§
impl Freeze for ModuleCache
impl !RefUnwindSafe for ModuleCache
impl Send for ModuleCache
impl Sync for ModuleCache
impl Unpin for ModuleCache
impl UnsafeUnpin for ModuleCache
impl UnwindSafe for ModuleCache
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> 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