pub struct SymbolTable { /* private fields */ }Expand description
A global symbol table for resolving cross-file references.
Implementations§
Source§impl SymbolTable
impl SymbolTable
pub fn new() -> Self
Sourcepub fn insert(&mut self, fqn: String, id: NodeId, file: PathBuf)
pub fn insert(&mut self, fqn: String, id: NodeId, file: PathBuf)
Registers a symbol definition.
Repeated FQNs accumulate instead of overwriting.
Sourcepub fn resolve(&self, fqn: &str) -> Option<NodeId>
pub fn resolve(&self, fqn: &str) -> Option<NodeId>
Resolves an exact FQN, but only when the definition is unambiguous.
Returns None for a colliding FQN so the caller can fall back to
context-aware resolution rather than picking a definition at random.
Sourcepub fn resolve_all(&self, fqn: &str) -> Vec<NodeId> ⓘ
pub fn resolve_all(&self, fqn: &str) -> Vec<NodeId> ⓘ
All nodes defining this exact FQN, in deterministic order.
Sourcepub fn get_file_exports(&self, file: &PathBuf) -> Option<&Vec<String>>
pub fn get_file_exports(&self, file: &PathBuf) -> Option<&Vec<String>>
Returns all symbols exported by a file.
pub fn clear(&mut self)
Sourcepub fn resolve_ref(&self, name: &str, context_file: &Path) -> Resolution
pub fn resolve_ref(&self, name: &str, context_file: &Path) -> Resolution
Resolves a reference, preferring locality and reporting ambiguity.
Order:
- Exact FQN, unique →
Exact - Candidate gathering: exact-FQN entries plus every segment-aligned suffix match, deduplicated and sorted
- Single candidate →
Exact/UniqueSuffix - Exactly one candidate in the referencing file →
SameFile - Exactly one candidate in the referencing directory →
SameDir - Otherwise →
Ambiguous
Sourcepub fn resolve_with_context(
&self,
name: &str,
context_file: &Path,
) -> Option<NodeId>
pub fn resolve_with_context( &self, name: &str, context_file: &Path, ) -> Option<NodeId>
Back-compatible wrapper returning only a confidently-resolved node.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for SymbolTable
impl Clone for SymbolTable
Source§fn clone(&self) -> SymbolTable
fn clone(&self) -> SymbolTable
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SymbolTable
impl Debug for SymbolTable
Source§impl Default for SymbolTable
impl Default for SymbolTable
Source§fn default() -> SymbolTable
fn default() -> SymbolTable
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SymbolTable
impl RefUnwindSafe for SymbolTable
impl Send for SymbolTable
impl Sync for SymbolTable
impl Unpin for SymbolTable
impl UnsafeUnpin for SymbolTable
impl UnwindSafe for SymbolTable
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