From d9c77c54534fcde7c432c6e11746d636d972a20b Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 8 Mar 2020 10:51:40 +0100 Subject: Handle visibility for path completion (not in all cases yet) --- crates/ra_hir/src/code_model.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index f93b43fb6..4d1e8f921 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -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) -> 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() } -- cgit v1.2.3