squawk-ide 2.50.0

Linter for Postgres migrations & SQL
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use rustc_hash::FxHashMap;

use crate::symbols::{Name, SymbolId};

#[derive(Default, Debug, Clone, PartialEq)]
pub(crate) struct Scope {
    pub(crate) entries: FxHashMap<Name, Vec<SymbolId>>,
}

impl Scope {
    pub(crate) fn insert(&mut self, name: Name, id: SymbolId) {
        self.entries.entry(name).or_default().push(id);
    }

    pub(crate) fn get(&self, name: &Name) -> Option<&[SymbolId]> {
        self.entries.get(name).map(|ids| ids.as_slice())
    }
}