pub struct ASTRegistry { /* private fields */ }Expand description
Complete AST storage for symbols
Stores the full PureItem AST for each symbol, enabling:
- Direct AST mutation without file I/O
- Complete AST reconstruction at dump time
- Simplified mutation logic (no type-specific storage)
§SSOT Design
- All items stored in unified
itemsmap via SymbolId - Module content stored in PureMod.items (Use statements, Impl blocks, etc.)
- Module children tracked in
module_childrenfor O(1) access - Binary entries: individual symbols registered in
items(no separate storage) - Inline modules tracked separately in
inline_modulesfor generation
Implementations§
Source§impl ASTRegistry
impl ASTRegistry
Sourcepub fn get_mut(&mut self, id: SymbolId) -> Option<&mut PureItem>
pub fn get_mut(&mut self, id: SymbolId) -> Option<&mut PureItem>
Get AST for a symbol (mutable)
Sourcepub fn set(&mut self, id: SymbolId, item: PureItem)
pub fn set(&mut self, id: SymbolId, item: PureItem)
Set AST for a symbol
Overwrites existing AST if present.
Sourcepub fn remove(&mut self, id: SymbolId) -> Option<PureItem>
pub fn remove(&mut self, id: SymbolId) -> Option<PureItem>
Remove AST for a symbol
Returns the removed AST if it existed.
Sourcepub fn iter(&self) -> impl Iterator<Item = (SymbolId, &PureItem)>
pub fn iter(&self) -> impl Iterator<Item = (SymbolId, &PureItem)>
Iterate all (SymbolId, &PureItem) pairs
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (SymbolId, &mut PureItem)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (SymbolId, &mut PureItem)>
Iterate all (SymbolId, &mut PureItem) pairs
Sourcepub fn mark_inline_module(&mut self, id: SymbolId)
pub fn mark_inline_module(&mut self, id: SymbolId)
Mark a module as inline (defined with mod name { ... } syntax)
Inline modules stay in their parent file during generation, while external modules get their own files.
Sourcepub fn is_inline_module(&self, id: SymbolId) -> bool
pub fn is_inline_module(&self, id: SymbolId) -> bool
Check if a module is inline
Sourcepub fn inline_module_ids(&self) -> impl Iterator<Item = SymbolId> + '_
pub fn inline_module_ids(&self) -> impl Iterator<Item = SymbolId> + '_
Get all inline module IDs
Sourcepub fn get_module_children(&self, module_id: SymbolId) -> Option<&Vec<SymbolId>>
pub fn get_module_children(&self, module_id: SymbolId) -> Option<&Vec<SymbolId>>
Get child symbol IDs for a module
Sourcepub fn get_module_children_mut(
&mut self,
module_id: SymbolId,
) -> Option<&mut Vec<SymbolId>>
pub fn get_module_children_mut( &mut self, module_id: SymbolId, ) -> Option<&mut Vec<SymbolId>>
Get child symbol IDs for a module (mutable)
Sourcepub fn set_module_children(
&mut self,
module_id: SymbolId,
children: Vec<SymbolId>,
)
pub fn set_module_children( &mut self, module_id: SymbolId, children: Vec<SymbolId>, )
Set child symbol IDs for a module
Sourcepub fn add_child_to_module(&mut self, module_id: SymbolId, child_id: SymbolId)
pub fn add_child_to_module(&mut self, module_id: SymbolId, child_id: SymbolId)
Add a child to a module
§Panics
Panics if module_id is not a valid SymbolId in the underlying SlotMap.
Callers are responsible for supplying a registered SymbolId.
Sourcepub fn remove_child_from_module(
&mut self,
module_id: SymbolId,
child_id: SymbolId,
)
pub fn remove_child_from_module( &mut self, module_id: SymbolId, child_id: SymbolId, )
Remove a child from a module
Sourcepub fn has_module_children(&self, module_id: SymbolId) -> bool
pub fn has_module_children(&self, module_id: SymbolId) -> bool
Check if module has children tracked
Sourcepub fn iter_module_children(
&self,
) -> impl Iterator<Item = (SymbolId, &Vec<SymbolId>)>
pub fn iter_module_children( &self, ) -> impl Iterator<Item = (SymbolId, &Vec<SymbolId>)>
Iterate all (ModuleSymbolId, &Vec<SymbolId>) pairs
Sourcepub fn get_module_items(&self, module_id: SymbolId) -> Option<&Vec<PureItem>>
pub fn get_module_items(&self, module_id: SymbolId) -> Option<&Vec<PureItem>>
Get all items for a module (including use statements, impl blocks)
Sourcepub fn get_module_items_mut(
&mut self,
module_id: SymbolId,
) -> Option<&mut Vec<PureItem>>
pub fn get_module_items_mut( &mut self, module_id: SymbolId, ) -> Option<&mut Vec<PureItem>>
Get all items for a module (mutable)
Sourcepub fn set_module_items(&mut self, module_id: SymbolId, items: Vec<PureItem>)
pub fn set_module_items(&mut self, module_id: SymbolId, items: Vec<PureItem>)
Set all items for a module.
If the module doesn’t exist in the AST registry yet, creates a new empty PureMod entry and sets its items. If items is empty and the module doesn’t exist, no entry is created (mod declarations are generated from module hierarchy, not stored in ASTRegistry).
Sourcepub fn has_module_items(&self, module_id: SymbolId) -> bool
pub fn has_module_items(&self, module_id: SymbolId) -> bool
Check if module has items stored
Sourcepub fn iter_module_items(
&self,
) -> impl Iterator<Item = (SymbolId, &Vec<PureItem>)>
pub fn iter_module_items( &self, ) -> impl Iterator<Item = (SymbolId, &Vec<PureItem>)>
Iterate all (ModuleSymbolId, &Vec<PureItem>) pairs
Sourcepub fn iter_module_items_mut(
&mut self,
) -> impl Iterator<Item = (SymbolId, &mut Vec<PureItem>)>
pub fn iter_module_items_mut( &mut self, ) -> impl Iterator<Item = (SymbolId, &mut Vec<PureItem>)>
Iterate all (ModuleSymbolId, &mut Vec<PureItem>) pairs
Sourcepub fn build_from_files(
files: &HashMap<WorkspaceFilePath, Arc<PureFile>>,
registry: &SymbolRegistry,
_crate_name: &str,
) -> Self
pub fn build_from_files( files: &HashMap<WorkspaceFilePath, Arc<PureFile>>, registry: &SymbolRegistry, _crate_name: &str, ) -> Self
Build ASTRegistry from parsed files.
Iterates over all files and stores PureItem for each symbol found in SymbolRegistry. This establishes the initial AST state before mutations.
§Arguments
files- Parsed files keyed by workspace pathregistry- Symbol registry with pre-registered symbolscrate_name- Crate name for path resolution
Trait Implementations§
Source§impl Clone for ASTRegistry
impl Clone for ASTRegistry
Source§fn clone(&self) -> ASTRegistry
fn clone(&self) -> ASTRegistry
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 ASTRegistry
impl Debug for ASTRegistry
Source§impl Default for ASTRegistry
impl Default for ASTRegistry
Source§fn default() -> ASTRegistry
fn default() -> ASTRegistry
Auto Trait Implementations§
impl Freeze for ASTRegistry
impl RefUnwindSafe for ASTRegistry
impl Send for ASTRegistry
impl Sync for ASTRegistry
impl Unpin for ASTRegistry
impl UnsafeUnpin for ASTRegistry
impl UnwindSafe for ASTRegistry
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> 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