Skip to main content

ASTMutationContext

Struct ASTMutationContext 

Source
pub struct ASTMutationContext<'a> {
    pub ast_registry: &'a mut ASTRegistry,
    pub symbol_registry: &'a mut SymbolRegistry,
    /* private fields */
}
Expand description

Context passed to ASTRegApply::apply_to_registry

Provides access to ASTRegistry, SymbolRegistry, and event emission.

§Binary Entry (main.rs) Support

Binary entry symbols (main.rs, src/bin/*.rs) are registered in the unified items map like library symbols. Use WorkspaceFilePath::is_binary_entry() to identify binary files when needed for file output.

Fields§

§ast_registry: &'a mut ASTRegistry

AST storage (complete PureItem per symbol)

§symbol_registry: &'a mut SymbolRegistry

Symbol metadata (path ↔ id, kind, span, etc.)

Implementations§

Source§

impl<'a> ASTMutationContext<'a>

Source

pub fn new( ast_registry: &'a mut ASTRegistry, symbol_registry: &'a mut SymbolRegistry, ) -> Self

Create a new mutation context

Source

pub fn into_events(self) -> Vec<MutationEvent>

Consume context and return collected events

Source

pub fn emit(&mut self, event: MutationEvent)

Emit an event (for logging/tracking)

Source

pub fn emit_added(&mut self, path: SymbolPath, kind: SymbolKind)

Emit symbol added event

Source

pub fn emit_removed(&mut self, path: SymbolPath)

Emit symbol removed event

Source

pub fn emit_modified(&mut self, id: SymbolId, modification: ModificationType)

Emit symbol modified event

Source

pub fn emit_renamed(&mut self, old_path: SymbolPath, new_path: SymbolPath)

Emit symbol renamed event

Source

pub fn get_ast(&self, id: SymbolId) -> Option<&PureItem>

Get AST for a symbol (immutable)

Source

pub fn get_ast_mut(&mut self, id: SymbolId) -> Option<&mut PureItem>

Get AST for a symbol (mutable)

Source

pub fn set_ast(&mut self, id: SymbolId, item: PureItem)

Set AST for a symbol

Source

pub fn has_ast(&self, id: SymbolId) -> bool

Check if symbol has AST

Source

pub fn lookup(&self, path: &SymbolPath) -> Option<SymbolId>

Lookup symbol by path

Source

pub fn path(&self, id: SymbolId) -> Option<&SymbolPath>

Get symbol path by ID

Source

pub fn kind(&self, id: SymbolId) -> Option<SymbolKind>

Get symbol kind by ID

Source

pub fn resolve_symbol_by_name( &self, name: &str, kinds: &[SymbolKind], ) -> Result<SymbolId, ResolveError>

Resolve symbol ID by name, supporting both simple name and full path.

  • If name contains “::”, performs full path match (always unique)
  • Otherwise, matches by last segment (symbol name) only
§Errors
  • ResolveError::NotFound - no matching symbol
  • ResolveError::Ambiguous - multiple symbols match (use full path)
§Example
// Find struct by simple name (fails if multiple "User" exist)
let id = ctx.resolve_symbol_by_name("User", &[SymbolKind::Struct])?;

// Find by full path (always unambiguous)
let id = ctx.resolve_symbol_by_name("crate::user::UserStatus", &[SymbolKind::Enum])?;
Source

pub fn register( &mut self, path: SymbolPath, kind: SymbolKind, ) -> Option<SymbolId>

Register new symbol (emits SymbolAdded event)

Returns None if registration fails (e.g., duplicate path).

Source

pub fn register_with_ast( &mut self, path: SymbolPath, kind: SymbolKind, ast: PureItem, ) -> Option<SymbolId>

Register new symbol with AST (emits SymbolAdded event)

Returns None if registration fails.

Source

pub fn remove_symbol(&mut self, id: SymbolId) -> Option<PureItem>

Remove symbol (emits SymbolRemoved event)

This removes the symbol from:

  1. SymbolRegistry (path → id mapping)
  2. ASTRegistry items (id → PureItem mapping)
  3. Parent module’s module_items list (for file generation)
Source

pub fn rename_symbol( &mut self, id: SymbolId, new_path: SymbolPath, ) -> Result<(), String>

Rename symbol (emits SymbolRenamed event)

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more