Add completion module tailored towards use trees

This commit is contained in:
Lukas Wirth 2022-02-02 15:03:46 +01:00
parent 6940cca760
commit 661d721e20
12 changed files with 270 additions and 165 deletions

View file

@ -452,6 +452,11 @@ impl Module {
Module { id: def_map.module_id(def_map.root()) }
}
pub fn is_crate_root(self, db: &dyn HirDatabase) -> bool {
let def_map = db.crate_def_map(self.id.krate());
def_map.root() == self.id.local_id
}
/// Iterates over all child modules.
pub fn children(self, db: &dyn HirDatabase) -> impl Iterator<Item = Module> {
let def_map = self.id.def_map(db.upcast());