mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Handle visibility for path completion (not in all cases yet)
This commit is contained in:
parent
734e68da4c
commit
d9c77c5453
2 changed files with 51 additions and 5 deletions
|
@ -204,10 +204,20 @@ impl Module {
|
|||
}
|
||||
|
||||
/// Returns a `ModuleScope`: a set of items, visible in this module.
|
||||
pub fn scope(self, db: &impl HirDatabase) -> Vec<(Name, ScopeDef)> {
|
||||
pub fn scope(self, db: &impl HirDatabase, visible_from: Option<Module>) -> Vec<(Name, ScopeDef)> {
|
||||
db.crate_def_map(self.id.krate)[self.id.local_id]
|
||||
.scope
|
||||
.entries()
|
||||
.filter_map(|(name, def)| if let Some(m) = visible_from {
|
||||
let filtered = def.filter_visibility(|vis| vis.is_visible_from(db, m.id));
|
||||
if filtered.is_none() && !def.is_none() {
|
||||
None
|
||||
} else {
|
||||
Some((name, filtered))
|
||||
}
|
||||
} else {
|
||||
Some((name, def))
|
||||
})
|
||||
.map(|(name, def)| (name.clone(), def.into()))
|
||||
.collect()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue