aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-03-08 09:51:40 +0000
committerFlorian Diebold <[email protected]>2020-03-08 09:51:40 +0000
commitd9c77c54534fcde7c432c6e11746d636d972a20b (patch)
treecdf44c613f55bdd99ab08490b32c185e9915c7bd /crates/ra_hir
parent734e68da4ceb1b15b3430302f233d4700d694728 (diff)
Handle visibility for path completion (not in all cases yet)
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model.rs12
1 files changed, 11 insertions, 1 deletions
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 {
204 } 204 }
205 205
206 /// Returns a `ModuleScope`: a set of items, visible in this module. 206 /// Returns a `ModuleScope`: a set of items, visible in this module.
207 pub fn scope(self, db: &impl HirDatabase) -> Vec<(Name, ScopeDef)> { 207 pub fn scope(self, db: &impl HirDatabase, visible_from: Option<Module>) -> Vec<(Name, ScopeDef)> {
208 db.crate_def_map(self.id.krate)[self.id.local_id] 208 db.crate_def_map(self.id.krate)[self.id.local_id]
209 .scope 209 .scope
210 .entries() 210 .entries()
211 .filter_map(|(name, def)| if let Some(m) = visible_from {
212 let filtered = def.filter_visibility(|vis| vis.is_visible_from(db, m.id));
213 if filtered.is_none() && !def.is_none() {
214 None
215 } else {
216 Some((name, filtered))
217 }
218 } else {
219 Some((name, def))
220 })
211 .map(|(name, def)| (name.clone(), def.into())) 221 .map(|(name, def)| (name.clone(), def.into()))
212 .collect() 222 .collect()
213 } 223 }