feat(els): add deep completion

This commit is contained in:
Shunsuke Shibayama 2023-03-10 13:26:13 +09:00
parent 257b38cec7
commit 0744c35517
7 changed files with 280 additions and 69 deletions

View file

@ -1034,6 +1034,10 @@ impl Context {
attrs
}
pub fn local_dir(&self) -> Dict<&VarName, &VarInfo> {
self.type_dir(self)
}
pub(crate) fn mod_cache(&self) -> &SharedModuleCache {
&self.shared().mod_cache
}

View file

@ -145,6 +145,10 @@ impl ModuleCache {
self.cache.insert(new, entry);
}
}
pub fn iter(&self) -> impl Iterator<Item = (&PathBuf, &ModuleEntry)> {
self.cache.iter()
}
}
#[derive(Debug, Clone, Default)]
@ -161,6 +165,14 @@ impl SharedModuleCache {
Self(Shared::new(ModuleCache::new()))
}
pub fn is_empty(&self) -> bool {
self.0.borrow().cache.is_empty()
}
pub fn len(&self) -> usize {
self.0.borrow().cache.len()
}
pub fn get<Q: Eq + Hash + ?Sized>(&self, path: &Q) -> Option<&ModuleEntry>
where
PathBuf: Borrow<Q>,
@ -230,4 +242,9 @@ impl SharedModuleCache {
pub fn rename_path(&self, path: &PathBuf, new: PathBuf) {
self.0.borrow_mut().rename_path(path, new);
}
pub fn iter(&self) -> impl Iterator<Item = (&PathBuf, &ModuleEntry)> {
let ref_ = unsafe { self.0.as_ptr().as_ref().unwrap() };
ref_.iter()
}
}