Add some more methods around this
This commit is contained in:
parent
f9633ebe55
commit
7a56b6dfc0
@ -115,12 +115,17 @@ impl SymbolTable {
|
|||||||
vec.push(ScopeSegment { name: local_name.clone(), kind: ScopeSegmentKind::Terminal });
|
vec.push(ScopeSegment { name: local_name.clone(), kind: ScopeSegmentKind::Terminal });
|
||||||
let fully_qualified_name = FullyQualifiedSymbolName(vec);
|
let fully_qualified_name = FullyQualifiedSymbolName(vec);
|
||||||
let symbol = Symbol { local_name: local_name.clone(), fully_qualified_name: fully_qualified_name.clone(), spec };
|
let symbol = Symbol { local_name: local_name.clone(), fully_qualified_name: fully_qualified_name.clone(), spec };
|
||||||
|
self.symbol_trie.insert(&fully_qualified_name);
|
||||||
self.symbol_path_to_symbol.insert(fully_qualified_name, symbol);
|
self.symbol_path_to_symbol.insert(fully_qualified_name, symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lookup_by_fqsn(&self, fully_qualified_path: &FullyQualifiedSymbolName) -> Option<&Symbol> {
|
pub fn lookup_by_fqsn(&self, fully_qualified_path: &FullyQualifiedSymbolName) -> Option<&Symbol> {
|
||||||
self.symbol_path_to_symbol.get(fully_qualified_path)
|
self.symbol_path_to_symbol.get(fully_qualified_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn lookup_children_of_fqsn(&self, path: &FullyQualifiedSymbolName) -> Vec<FullyQualifiedSymbolName> {
|
||||||
|
self.symbol_trie.get_children(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -4,6 +4,7 @@ use super::{ScopeSegmentKind, ScopeSegment, FullyQualifiedSymbolName};
|
|||||||
use std::hash::{Hasher, Hash};
|
use std::hash::{Hasher, Hash};
|
||||||
use std::collections::hash_map::DefaultHasher;
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct SymbolTrie(Trie<FullyQualifiedSymbolName, ()>);
|
pub struct SymbolTrie(Trie<FullyQualifiedSymbolName, ()>);
|
||||||
|
|
||||||
impl TrieKey for FullyQualifiedSymbolName {
|
impl TrieKey for FullyQualifiedSymbolName {
|
||||||
@ -33,7 +34,7 @@ impl SymbolTrie {
|
|||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => return vec![]
|
None => return vec![]
|
||||||
};
|
};
|
||||||
let output: Vec<FullyQualifiedSymbolName> = subtrie.keys().map(|fqsn| fqsn.clone()).collect();
|
let output: Vec<FullyQualifiedSymbolName> = subtrie.keys().filter(|cur_key| **cur_key != *fqsn).map(|fqsn| fqsn.clone()).collect();
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user