pub struct SymbolTable {
pub symbols: HashMap<String, Vec<Symbol>>,
pub references: HashMap<String, Vec<SymbolReference>>,
pub scopes: HashMap<usize, Scope>,
/* private fields */
}Expand description
Symbol extraction, table, and reference types for navigation. Comprehensive symbol table for Perl code analysis and LSP features in Index/Analyze stages.
Central data structure containing all symbols, references, and scopes with efficient indexing for LSP operations like go-to-definition, find-references, and workspace symbols.
§Performance Characteristics
- Symbol lookup: O(1) average, O(n) worst case for overloaded names
- Reference queries: O(log n) with spatial indexing
- Memory usage: ~500KB per 10K lines of Perl code
- Construction time: O(n) single-pass AST traversal
§LSP Integration
Core data structure for:
- Symbol resolution: Package-qualified and bare name lookup
- Reference tracking: All usage sites with context
- Scope analysis: Lexical visibility and shadowing
- Completion: Context-aware symbol suggestions
- Workspace indexing: Cross-file symbol registry
§Perl Language Support
- Package qualification:
Package::symbolresolution - Lexical scoping:
my,our,local,statevariable semantics - Symbol overloading: Multiple definitions with scope precedence
- Context sensitivity: Scalar/array/hash context resolution
Fields§
§symbols: HashMap<String, Vec<Symbol>>Symbols indexed by name with multiple definitions support
references: HashMap<String, Vec<SymbolReference>>References indexed by name for find-all-references
scopes: HashMap<usize, Scope>Scopes indexed by ID for hierarchical lookup
Implementations§
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn new() -> SymbolTable
pub fn new() -> SymbolTable
Create a new symbol table for Index/Analyze workflows.
Sourcepub fn find_symbol(
&self,
name: &str,
from_scope: usize,
kind: SymbolKind,
) -> Vec<&Symbol>
pub fn find_symbol( &self, name: &str, from_scope: usize, kind: SymbolKind, ) -> Vec<&Symbol>
Find symbol definitions visible from a given scope for Navigate/Analyze workflows.
Sourcepub fn find_references(&self, symbol: &Symbol) -> Vec<&SymbolReference>
pub fn find_references(&self, symbol: &Symbol) -> Vec<&SymbolReference>
Get all references to a symbol for Navigate/Analyze workflows.
Trait Implementations§
Source§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