mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
minor cleanup
This commit is contained in:
parent
e53c916ce2
commit
260ae2dbc9
3 changed files with 38 additions and 33 deletions
|
@ -111,37 +111,37 @@ pub trait DefDatabase: InternDatabase + HirDebugDatabase {
|
|||
#[salsa::invoke(CrateDefMap::crate_def_map_query)]
|
||||
fn crate_def_map(&self, krate: Crate) -> Arc<CrateDefMap>;
|
||||
|
||||
#[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<ModuleImplBlocks>, Arc<ImplSourceMap>);
|
||||
|
||||
#[salsa::invoke(crate::impl_block::impls_in_module)]
|
||||
#[salsa::invoke(ModuleImplBlocks::impls_in_module_query)]
|
||||
fn impls_in_module(&self, module: Module) -> Arc<ModuleImplBlocks>;
|
||||
|
||||
#[salsa::invoke(crate::generics::GenericParams::generic_params_query)]
|
||||
fn generic_params(&self, def: GenericDef) -> Arc<GenericParams>;
|
||||
|
||||
#[salsa::invoke(crate::FnData::fn_data_query)]
|
||||
#[salsa::invoke(FnData::fn_data_query)]
|
||||
fn fn_data(&self, func: Function) -> Arc<FnData>;
|
||||
|
||||
#[salsa::invoke(crate::type_alias::type_alias_data_query)]
|
||||
#[salsa::invoke(TypeAliasData::type_alias_data_query)]
|
||||
fn type_alias_data(&self, typ: TypeAlias) -> Arc<TypeAliasData>;
|
||||
|
||||
#[salsa::invoke(crate::ConstData::const_data_query)]
|
||||
#[salsa::invoke(ConstData::const_data_query)]
|
||||
fn const_data(&self, konst: Const) -> Arc<ConstData>;
|
||||
|
||||
#[salsa::invoke(crate::ConstData::static_data_query)]
|
||||
#[salsa::invoke(ConstData::static_data_query)]
|
||||
fn static_data(&self, konst: Static) -> Arc<ConstData>;
|
||||
|
||||
#[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<Arc<LangItems>>;
|
||||
|
||||
#[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<LangItems>;
|
||||
|
||||
#[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<LangItemTarget>;
|
||||
|
||||
#[salsa::invoke(crate::code_model::docs::documentation_query)]
|
||||
|
|
|
@ -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<ModuleImplBlocks>, Arc<ImplSourceMap>) {
|
||||
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<ModuleImplBlocks> {
|
||||
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<ModuleImplBlocks>, Arc<ImplSourceMap>) {
|
||||
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<ModuleImplBlocks> {
|
||||
db.impls_in_module_with_source_map(module).0
|
||||
}
|
||||
|
|
|
@ -17,12 +17,14 @@ pub struct TypeAliasData {
|
|||
pub(crate) type_ref: Option<TypeRef>,
|
||||
}
|
||||
|
||||
pub(crate) fn type_alias_data_query(
|
||||
db: &(impl DefDatabase + AstDatabase),
|
||||
typ: TypeAlias,
|
||||
) -> Arc<TypeAliasData> {
|
||||
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<TypeAliasData> {
|
||||
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 })
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue