From e1a2961273bdf7ef24c81f22fe86041a20812365 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 26 Dec 2019 15:57:14 +0100 Subject: Rename Visibility -> RawVisibility --- crates/ra_hir_def/src/db.rs | 6 ++-- crates/ra_hir_def/src/nameres/collector.rs | 2 +- crates/ra_hir_def/src/nameres/path_resolution.rs | 8 ++--- crates/ra_hir_def/src/nameres/raw.rs | 18 +++++------ crates/ra_hir_def/src/resolver.rs | 8 ++--- crates/ra_hir_def/src/visibility.rs | 38 ++++++++++++------------ 6 files changed, 40 insertions(+), 40 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index 1761e2187..6bc0a8486 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs @@ -14,7 +14,7 @@ use crate::{ generics::GenericParams, lang_item::{LangItemTarget, LangItems}, nameres::{raw::RawItems, CrateDefMap}, - visibility::Visibility, + visibility::RawVisibility, AttrDefId, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc, FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, ModuleId, StaticId, StaticLoc, StructId, StructLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc, VisibilityDefId, @@ -91,8 +91,8 @@ pub trait DefDatabase: InternDatabase + AstDatabase { #[salsa::invoke(Attrs::attrs_query)] fn attrs(&self, def: AttrDefId) -> Attrs; - #[salsa::invoke(Visibility::visibility_query)] - fn visibility(&self, def: VisibilityDefId) -> Visibility; + #[salsa::invoke(RawVisibility::visibility_query)] + fn visibility(&self, def: VisibilityDefId) -> RawVisibility; #[salsa::invoke(LangItems::module_lang_items_query)] fn module_lang_items(&self, module: ModuleId) -> Option>; diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index a80c4f8e9..f4678d145 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -743,7 +743,7 @@ where name: Name, declaration: AstId, definition: Option, - visibility: &crate::visibility::Visibility, + visibility: &crate::visibility::RawVisibility, ) -> LocalModuleId { let vis = self .def_collector diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index a56e3f08b..8a6256eee 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs @@ -21,7 +21,7 @@ use crate::{ nameres::{BuiltinShadowMode, CrateDefMap}, path::{ModPath, PathKind}, per_ns::PerNs, - visibility::{ResolvedVisibility, Visibility}, + visibility::{RawVisibility, ResolvedVisibility}, AdtId, CrateId, EnumVariantId, LocalModuleId, ModuleDefId, ModuleId, }; @@ -71,10 +71,10 @@ impl CrateDefMap { &self, db: &impl DefDatabase, original_module: LocalModuleId, - visibility: &Visibility, + visibility: &RawVisibility, ) -> Option { match visibility { - Visibility::Module(path) => { + RawVisibility::Module(path) => { let (result, remaining) = self.resolve_path(db, original_module, &path, BuiltinShadowMode::Module); if remaining.is_some() { @@ -89,7 +89,7 @@ impl CrateDefMap { } } } - Visibility::Public => Some(ResolvedVisibility::Public), + RawVisibility::Public => Some(ResolvedVisibility::Public), } } diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 59f79f7cd..fac1169ef 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -22,7 +22,7 @@ use ra_syntax::{ use test_utils::tested_by; use crate::{ - attr::Attrs, db::DefDatabase, path::ModPath, visibility::Visibility, FileAstId, HirFileId, + attr::Attrs, db::DefDatabase, path::ModPath, visibility::RawVisibility, FileAstId, HirFileId, InFile, }; @@ -127,12 +127,12 @@ impl_arena_id!(Module); pub(super) enum ModuleData { Declaration { name: Name, - visibility: Visibility, + visibility: RawVisibility, ast_id: FileAstId, }, Definition { name: Name, - visibility: Visibility, + visibility: RawVisibility, ast_id: FileAstId, items: Vec, }, @@ -150,7 +150,7 @@ pub struct ImportData { pub(super) is_prelude: bool, pub(super) is_extern_crate: bool, pub(super) is_macro_use: bool, - pub(super) visibility: Visibility, + pub(super) visibility: RawVisibility, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -161,7 +161,7 @@ impl_arena_id!(Def); pub(super) struct DefData { pub(super) name: Name, pub(super) kind: DefKind, - pub(super) visibility: Visibility, + pub(super) visibility: RawVisibility, } #[derive(Debug, PartialEq, Eq, Clone, Copy)] @@ -232,7 +232,7 @@ impl RawItemsCollector { fn add_item(&mut self, current_module: Option, item: ast::ModuleItem) { let attrs = self.parse_attrs(&item); - let visibility = Visibility::from_ast_with_hygiene(item.visibility(), &self.hygiene); + let visibility = RawVisibility::from_ast_with_hygiene(item.visibility(), &self.hygiene); let (kind, name) = match item { ast::ModuleItem::Module(module) => { self.add_module(current_module, module); @@ -292,7 +292,7 @@ impl RawItemsCollector { None => return, }; let attrs = self.parse_attrs(&module); - let visibility = Visibility::from_ast_with_hygiene(module.visibility(), &self.hygiene); + let visibility = RawVisibility::from_ast_with_hygiene(module.visibility(), &self.hygiene); let ast_id = self.source_ast_id_map.ast_id(&module); if module.has_semi() { @@ -320,7 +320,7 @@ impl RawItemsCollector { // FIXME: cfg_attr let is_prelude = use_item.has_atom_attr("prelude_import"); let attrs = self.parse_attrs(&use_item); - let visibility = Visibility::from_ast_with_hygiene(use_item.visibility(), &self.hygiene); + let visibility = RawVisibility::from_ast_with_hygiene(use_item.visibility(), &self.hygiene); let mut buf = Vec::new(); ModPath::expand_use_item( @@ -352,7 +352,7 @@ impl RawItemsCollector { if let Some(name_ref) = extern_crate.name_ref() { let path = ModPath::from_name_ref(&name_ref); let visibility = - Visibility::from_ast_with_hygiene(extern_crate.visibility(), &self.hygiene); + RawVisibility::from_ast_with_hygiene(extern_crate.visibility(), &self.hygiene); let alias = extern_crate.alias().and_then(|a| a.name()).map(|it| it.as_name()); let attrs = self.parse_attrs(&extern_crate); // FIXME: cfg_attr diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 950bf6c79..8e7a83ffe 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs @@ -19,7 +19,7 @@ use crate::{ nameres::CrateDefMap, path::{ModPath, PathKind}, per_ns::PerNs, - visibility::{ResolvedVisibility, Visibility}, + visibility::{RawVisibility, ResolvedVisibility}, AdtId, AssocContainerId, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, GenericDefId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, VariantId, @@ -235,17 +235,17 @@ impl Resolver { pub fn resolve_visibility( &self, db: &impl DefDatabase, - visibility: &Visibility, + visibility: &RawVisibility, ) -> Option { match visibility { - Visibility::Module(_) => { + RawVisibility::Module(_) => { let (item_map, module) = match self.module() { Some(it) => it, None => return None, }; item_map.resolve_visibility(db, module, visibility) } - Visibility::Public => Some(ResolvedVisibility::Public), + RawVisibility::Public => Some(ResolvedVisibility::Public), } } diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs index 990b2975c..b11e9bc52 100644 --- a/crates/ra_hir_def/src/visibility.rs +++ b/crates/ra_hir_def/src/visibility.rs @@ -16,7 +16,7 @@ use crate::{ /// Visibility of an item, not yet resolved. #[derive(Debug, Clone, PartialEq, Eq)] -pub enum Visibility { +pub enum RawVisibility { // FIXME: We could avoid the allocation in many cases by special-casing // pub(crate), pub(super) and private. Alternatively, `ModPath` could be // made to contain an Arc<[Segment]> instead of a Vec? @@ -27,16 +27,16 @@ pub enum Visibility { Public, } -impl Visibility { - pub(crate) fn visibility_query(db: &impl DefDatabase, def: VisibilityDefId) -> Visibility { +impl RawVisibility { + pub(crate) fn visibility_query(db: &impl DefDatabase, def: VisibilityDefId) -> RawVisibility { match def { VisibilityDefId::ModuleId(module) => { let def_map = db.crate_def_map(module.krate); let src = match def_map[module.local_id].declaration_source(db) { Some(it) => it, - None => return Visibility::private(), + None => return RawVisibility::private(), }; - Visibility::from_ast(db, src.map(|it| it.visibility())) + RawVisibility::from_ast(db, src.map(|it| it.visibility())) } VisibilityDefId::StructFieldId(it) => { let src = it.parent.child_source(db); @@ -49,9 +49,9 @@ impl Visibility { Either::Right(record) => record.visibility(), }); if vis_node.value.is_none() && is_enum { - Visibility::Public + RawVisibility::Public } else { - Visibility::from_ast(db, vis_node) + RawVisibility::from_ast(db, vis_node) } } VisibilityDefId::AdtId(it) => match it { @@ -67,41 +67,41 @@ impl Visibility { } } - fn private() -> Visibility { + fn private() -> RawVisibility { let path = ModPath { kind: PathKind::Super(0), segments: Vec::new() }; - Visibility::Module(Arc::new(path)) + RawVisibility::Module(Arc::new(path)) } - fn from_ast(db: &impl DefDatabase, node: InFile>) -> Visibility { + fn from_ast(db: &impl DefDatabase, node: InFile>) -> RawVisibility { Self::from_ast_with_hygiene(node.value, &Hygiene::new(db, node.file_id)) } pub(crate) fn from_ast_with_hygiene( node: Option, hygiene: &Hygiene, - ) -> Visibility { + ) -> RawVisibility { let node = match node { - None => return Visibility::private(), + None => return RawVisibility::private(), Some(node) => node, }; match node.kind() { ast::VisibilityKind::In(path) => { let path = ModPath::from_src(path, hygiene); let path = match path { - None => return Visibility::private(), + None => return RawVisibility::private(), Some(path) => path, }; - Visibility::Module(Arc::new(path)) + RawVisibility::Module(Arc::new(path)) } ast::VisibilityKind::PubCrate => { let path = ModPath { kind: PathKind::Crate, segments: Vec::new() }; - Visibility::Module(Arc::new(path)) + RawVisibility::Module(Arc::new(path)) } ast::VisibilityKind::PubSuper => { let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() }; - Visibility::Module(Arc::new(path)) + RawVisibility::Module(Arc::new(path)) } - ast::VisibilityKind::Pub => Visibility::Public, + ast::VisibilityKind::Pub => RawVisibility::Public, } } @@ -156,11 +156,11 @@ impl ResolvedVisibility { } } -fn visibility_from_loc(node: T, db: &impl DefDatabase) -> Visibility +fn visibility_from_loc(node: T, db: &impl DefDatabase) -> RawVisibility where T: HasSource, T::Value: ast::VisibilityOwner, { let src = node.source(db); - Visibility::from_ast(db, src.map(|n| n.visibility())) + RawVisibility::from_ast(db, src.map(|n| n.visibility())) } -- cgit v1.2.3