veryl_parser/
doc_comment_table.rs1use crate::resource_table::{PathId, StrId};
2use std::cell::RefCell;
3use std::collections::HashMap;
4
5#[derive(Clone, Debug, Default)]
6pub struct DocCommentTable {
7 table: HashMap<(PathId, u32), StrId>,
8}
9
10impl DocCommentTable {
11 pub fn insert(&mut self, path: PathId, line: u32, text: StrId) {
12 self.table.insert((path, line), text);
13 }
14
15 pub fn get(&self, path: PathId, line: u32) -> Option<StrId> {
16 self.table.get(&(path, line)).cloned()
17 }
18}
19
20thread_local!(static DOC_COMMENT_TABLE: RefCell<DocCommentTable> = RefCell::new(DocCommentTable::default()));
21
22pub fn insert(path: PathId, line: u32, text: StrId) {
23 DOC_COMMENT_TABLE.with(|f| f.borrow_mut().insert(path, line, text))
24}
25
26pub fn get(path: PathId, line: u32) -> Option<StrId> {
27 DOC_COMMENT_TABLE.with(|f| f.borrow().get(path, line))
28}