mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-27 19:59:07 +00:00
fix: module cache bug
This commit is contained in:
parent
c14a60e329
commit
a31f23a093
5 changed files with 33 additions and 4 deletions
|
@ -77,6 +77,16 @@ impl SharedCompilerResource {
|
|||
self.warns.remove(path);
|
||||
}
|
||||
|
||||
pub fn clear_path(&self, path: &NormalizedPathBuf) {
|
||||
self.mod_cache.remove(path);
|
||||
self.py_mod_cache.remove(path);
|
||||
self.index.remove_path(path);
|
||||
// self.graph.remove(path);
|
||||
self.promises.remove(path);
|
||||
self.errors.remove(path);
|
||||
self.warns.remove(path);
|
||||
}
|
||||
|
||||
pub fn rename_path(&self, old: &NormalizedPathBuf, new: NormalizedPathBuf) {
|
||||
self.mod_cache.rename_path(old, new.clone());
|
||||
self.py_mod_cache.rename_path(old, new.clone());
|
||||
|
|
|
@ -64,6 +64,7 @@ impl ModuleGraph {
|
|||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// (usually) `path` is not contained
|
||||
pub fn children(&self, path: &NormalizedPathBuf) -> Set<NormalizedPathBuf> {
|
||||
self.0
|
||||
.iter()
|
||||
|
@ -72,6 +73,7 @@ impl ModuleGraph {
|
|||
.collect()
|
||||
}
|
||||
|
||||
/// (usually) `path` is not contained
|
||||
fn parents(&self, path: &NormalizedPathBuf) -> Option<&Set<NormalizedPathBuf>> {
|
||||
self.0.iter().find(|n| &n.id == path).map(|n| &n.depends_on)
|
||||
}
|
||||
|
@ -200,10 +202,12 @@ impl SharedModuleGraph {
|
|||
self.0.borrow().depends_on(path, target)
|
||||
}
|
||||
|
||||
/// (usually) `path` is not contained
|
||||
pub fn children(&self, path: &NormalizedPathBuf) -> Set<NormalizedPathBuf> {
|
||||
self.0.borrow().children(path)
|
||||
}
|
||||
|
||||
/// (usually) `path` is not contained
|
||||
pub fn ancestors(&self, path: &NormalizedPathBuf) -> Set<NormalizedPathBuf> {
|
||||
self.0.borrow().ancestors(path)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue