From 9fd2c813ca355c3a1f10f54993c16e81778b867b Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 27 Dec 2019 11:24:31 +0100 Subject: [PATCH] visible_from -> is_visible_from --- crates/ra_hir/src/code_model.rs | 4 ++-- crates/ra_hir_def/src/nameres/collector.rs | 6 +++--- crates/ra_hir_def/src/visibility.rs | 8 ++++---- crates/ra_ide/src/completion/complete_dot.rs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 9612c86da5..488f74cfb1 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -1053,8 +1053,8 @@ impl + Copy> Docs for T { pub trait HasVisibility { fn visibility(&self, db: &impl HirDatabase) -> Visibility; - fn visible_from(&self, db: &impl HirDatabase, module: Module) -> bool { + fn is_visible_from(&self, db: &impl HirDatabase, module: Module) -> bool { let vis = self.visibility(db); - vis.visible_from(db, module.id) + vis.is_visible_from(db, module.id) } } diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 30771d5106..8a22b05859 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -378,7 +378,7 @@ where .resolutions() // only keep visible names... .map(|(n, res)| { - (n, res.filter_visibility(|v| v.visible_from_other_crate())) + (n, res.filter_visibility(|v| v.is_visible_from_other_crate())) }) .filter(|(_, res)| !res.is_none()) .collect::>(); @@ -398,7 +398,7 @@ where ( n, res.filter_visibility(|v| { - v.visible_from_def_map(&self.def_map, module_id) + v.is_visible_from_def_map(&self.def_map, module_id) }), ) }) @@ -492,7 +492,7 @@ where for (glob_importing_module, glob_import_vis) in glob_imports { // we know all resolutions have the same visibility (`vis`), so we // just need to check that once - if !vis.visible_from_def_map(&self.def_map, glob_importing_module) { + if !vis.is_visible_from_def_map(&self.def_map, glob_importing_module) { continue; } self.update_recursive(glob_importing_module, resolutions, glob_import_vis, depth + 1); diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs index ad3f099810..d8296da4b6 100644 --- a/crates/ra_hir_def/src/visibility.rs +++ b/crates/ra_hir_def/src/visibility.rs @@ -81,7 +81,7 @@ pub enum Visibility { } impl Visibility { - pub fn visible_from(self, db: &impl DefDatabase, from_module: ModuleId) -> bool { + pub fn is_visible_from(self, db: &impl DefDatabase, from_module: ModuleId) -> bool { let to_module = match self { Visibility::Module(m) => m, Visibility::Public => return true, @@ -91,17 +91,17 @@ impl Visibility { return false; } let def_map = db.crate_def_map(from_module.krate); - self.visible_from_def_map(&def_map, from_module.local_id) + self.is_visible_from_def_map(&def_map, from_module.local_id) } - pub(crate) fn visible_from_other_crate(self) -> bool { + pub(crate) fn is_visible_from_other_crate(self) -> bool { match self { Visibility::Module(_) => false, Visibility::Public => true, } } - pub(crate) fn visible_from_def_map( + pub(crate) fn is_visible_from_def_map( self, def_map: &crate::nameres::CrateDefMap, from_module: crate::LocalModuleId, diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs index 13546c143b..210a685e40 100644 --- a/crates/ra_ide/src/completion/complete_dot.rs +++ b/crates/ra_ide/src/completion/complete_dot.rs @@ -38,7 +38,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: &Type) { for receiver in receiver.autoderef(ctx.db) { for (field, ty) in receiver.fields(ctx.db) { - if ctx.module.map_or(false, |m| !field.visible_from(ctx.db, m)) { + if ctx.module.map_or(false, |m| !field.is_visible_from(ctx.db, m)) { // Skip private field. FIXME: If the definition location of the // field is editable, we should show the completion continue;