#![cfg_attr(coverage_nightly, coverage(off))]
use crate::models::unified_ast::{BytePos, Location, QualifiedName, RelativeLocation, Span};
use dashmap::DashMap;
use std::path::Path;
use std::sync::Arc;
use tracing::debug;
#[derive(Debug)]
pub struct SymbolTable {
symbols: DashMap<QualifiedName, Location>,
span_index: DashMap<std::path::PathBuf, Vec<(BytePos, QualifiedName)>>,
}
impl Default for SymbolTable {
fn default() -> Self {
Self::new()
}
}
pub struct SymbolTableBuilder {
table: Arc<SymbolTable>,
}
impl SymbolTableBuilder {
#[must_use]
pub fn new() -> Self {
Self {
table: Arc::new(SymbolTable::new()),
}
}
pub fn add_symbol(&self, qualified_name: QualifiedName, location: Location) {
self.table.insert(qualified_name, location);
}
#[must_use]
pub fn build(self) -> Arc<SymbolTable> {
self.table
}
}
impl Default for SymbolTableBuilder {
fn default() -> Self {
Self::new()
}
}
include!("symbol_table_methods.rs");
include!("symbol_table_tests.rs");