From 260ae2dbc99a6e56228525baca57317ecd8306dc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 16 Oct 2019 13:26:02 +0300 Subject: [PATCH] minor cleanup --- crates/ra_hir/src/db.rs | 18 ++++++++--------- crates/ra_hir/src/impl_block.rs | 35 ++++++++++++++++++--------------- crates/ra_hir/src/type_alias.rs | 18 +++++++++-------- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 73d7d6fb662..489a3b19cab 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -111,37 +111,37 @@ pub trait DefDatabase: InternDatabase + HirDebugDatabase { #[salsa::invoke(CrateDefMap::crate_def_map_query)] fn crate_def_map(&self, krate: Crate) -> Arc; - #[salsa::invoke(crate::impl_block::impls_in_module_with_source_map_query)] + #[salsa::invoke(ModuleImplBlocks::impls_in_module_with_source_map_query)] fn impls_in_module_with_source_map( &self, module: Module, ) -> (Arc, Arc); - #[salsa::invoke(crate::impl_block::impls_in_module)] + #[salsa::invoke(ModuleImplBlocks::impls_in_module_query)] fn impls_in_module(&self, module: Module) -> Arc; #[salsa::invoke(crate::generics::GenericParams::generic_params_query)] fn generic_params(&self, def: GenericDef) -> Arc; - #[salsa::invoke(crate::FnData::fn_data_query)] + #[salsa::invoke(FnData::fn_data_query)] fn fn_data(&self, func: Function) -> Arc; - #[salsa::invoke(crate::type_alias::type_alias_data_query)] + #[salsa::invoke(TypeAliasData::type_alias_data_query)] fn type_alias_data(&self, typ: TypeAlias) -> Arc; - #[salsa::invoke(crate::ConstData::const_data_query)] + #[salsa::invoke(ConstData::const_data_query)] fn const_data(&self, konst: Const) -> Arc; - #[salsa::invoke(crate::ConstData::static_data_query)] + #[salsa::invoke(ConstData::static_data_query)] fn static_data(&self, konst: Static) -> Arc; - #[salsa::invoke(crate::lang_item::LangItems::module_lang_items_query)] + #[salsa::invoke(LangItems::module_lang_items_query)] fn module_lang_items(&self, module: Module) -> Option>; - #[salsa::invoke(crate::lang_item::LangItems::crate_lang_items_query)] + #[salsa::invoke(LangItems::crate_lang_items_query)] fn crate_lang_items(&self, krate: Crate) -> Arc; - #[salsa::invoke(crate::lang_item::LangItems::lang_item_query)] + #[salsa::invoke(LangItems::lang_item_query)] fn lang_item(&self, start_crate: Crate, item: SmolStr) -> Option; #[salsa::invoke(crate::code_model::docs::documentation_query)] diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index 55dfc393b40..33ef875636d 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs @@ -176,6 +176,25 @@ pub struct ModuleImplBlocks { } impl ModuleImplBlocks { + pub(crate) fn impls_in_module_with_source_map_query( + db: &(impl DefDatabase + AstDatabase), + module: Module, + ) -> (Arc, Arc) { + let mut source_map = ImplSourceMap::default(); + let crate_graph = db.crate_graph(); + let cfg_options = crate_graph.cfg_options(module.krate.crate_id()); + + let result = ModuleImplBlocks::collect(db, cfg_options, module, &mut source_map); + (Arc::new(result), Arc::new(source_map)) + } + + pub(crate) fn impls_in_module_query( + db: &impl DefDatabase, + module: Module, + ) -> Arc { + db.impls_in_module_with_source_map(module).0 + } + fn collect( db: &(impl DefDatabase + AstDatabase), cfg_options: &CfgOptions, @@ -264,19 +283,3 @@ impl ModuleImplBlocks { } } } - -pub(crate) fn impls_in_module_with_source_map_query( - db: &(impl DefDatabase + AstDatabase), - module: Module, -) -> (Arc, Arc) { - let mut source_map = ImplSourceMap::default(); - let crate_graph = db.crate_graph(); - let cfg_options = crate_graph.cfg_options(module.krate.crate_id()); - - let result = ModuleImplBlocks::collect(db, cfg_options, module, &mut source_map); - (Arc::new(result), Arc::new(source_map)) -} - -pub(crate) fn impls_in_module(db: &impl DefDatabase, module: Module) -> Arc { - db.impls_in_module_with_source_map(module).0 -} diff --git a/crates/ra_hir/src/type_alias.rs b/crates/ra_hir/src/type_alias.rs index 3b38c4740a7..674a4610204 100644 --- a/crates/ra_hir/src/type_alias.rs +++ b/crates/ra_hir/src/type_alias.rs @@ -17,12 +17,14 @@ pub struct TypeAliasData { pub(crate) type_ref: Option, } -pub(crate) fn type_alias_data_query( - db: &(impl DefDatabase + AstDatabase), - typ: TypeAlias, -) -> Arc { - let node = typ.source(db).ast; - let name = node.name().map_or_else(Name::missing, |n| n.as_name()); - let type_ref = node.type_ref().map(TypeRef::from_ast); - Arc::new(TypeAliasData { name, type_ref }) +impl TypeAliasData { + pub(crate) fn type_alias_data_query( + db: &(impl DefDatabase + AstDatabase), + typ: TypeAlias, + ) -> Arc { + let node = typ.source(db).ast; + let name = node.name().map_or_else(Name::missing, |n| n.as_name()); + let type_ref = node.type_ref().map(TypeRef::from_ast); + Arc::new(TypeAliasData { name, type_ref }) + } }