2019-10-30 05:10:38 -05:00
|
|
|
//! Defines database & queries for name resolution.
|
2019-10-30 08:12:55 -05:00
|
|
|
use std::sync::Arc;
|
2019-10-30 05:10:38 -05:00
|
|
|
|
2019-10-30 08:12:55 -05:00
|
|
|
use hir_expand::{db::AstDatabase, HirFileId};
|
2019-10-31 10:45:10 -05:00
|
|
|
use ra_db::{salsa, CrateId, SourceDatabase};
|
2019-10-30 05:10:38 -05:00
|
|
|
use ra_syntax::ast;
|
|
|
|
|
2019-10-31 08:40:36 -05:00
|
|
|
use crate::{
|
|
|
|
adt::{EnumData, StructData},
|
2019-11-14 08:37:22 -06:00
|
|
|
body::{scope::ExprScopes, Body, BodySourceMap},
|
2019-11-22 09:46:39 -06:00
|
|
|
data::{ConstData, FunctionData, ImplData, TraitData, TypeAliasData},
|
2019-11-20 11:33:18 -06:00
|
|
|
generics::GenericParams,
|
2019-10-31 10:45:10 -05:00
|
|
|
nameres::{
|
|
|
|
raw::{ImportSourceMap, RawItems},
|
|
|
|
CrateDefMap,
|
|
|
|
},
|
2019-11-22 09:46:39 -06:00
|
|
|
ConstId, DefWithBodyId, EnumId, FunctionId, GenericDefId, ImplId, ItemLoc, StaticId,
|
|
|
|
StructOrUnionId, TraitId, TypeAliasId,
|
2019-10-31 08:40:36 -05:00
|
|
|
};
|
2019-10-30 08:12:55 -05:00
|
|
|
|
2019-10-30 05:10:38 -05:00
|
|
|
#[salsa::query_group(InternDatabaseStorage)]
|
|
|
|
pub trait InternDatabase: SourceDatabase {
|
|
|
|
#[salsa::interned]
|
2019-11-20 08:39:58 -06:00
|
|
|
fn intern_function(&self, loc: crate::FunctionLoc) -> crate::FunctionId;
|
2019-10-30 05:10:38 -05:00
|
|
|
#[salsa::interned]
|
2019-11-15 10:14:50 -06:00
|
|
|
fn intern_struct_or_union(&self, loc: ItemLoc<ast::StructDef>) -> crate::StructOrUnionId;
|
2019-10-30 08:12:55 -05:00
|
|
|
#[salsa::interned]
|
2019-11-15 10:14:50 -06:00
|
|
|
fn intern_enum(&self, loc: ItemLoc<ast::EnumDef>) -> crate::EnumId;
|
2019-10-30 05:10:38 -05:00
|
|
|
#[salsa::interned]
|
2019-11-20 09:00:01 -06:00
|
|
|
fn intern_const(&self, loc: crate::ConstLoc) -> crate::ConstId;
|
2019-10-30 05:10:38 -05:00
|
|
|
#[salsa::interned]
|
2019-11-15 10:14:50 -06:00
|
|
|
fn intern_static(&self, loc: ItemLoc<ast::StaticDef>) -> crate::StaticId;
|
2019-10-30 05:10:38 -05:00
|
|
|
#[salsa::interned]
|
2019-11-15 10:14:50 -06:00
|
|
|
fn intern_trait(&self, loc: ItemLoc<ast::TraitDef>) -> crate::TraitId;
|
2019-10-30 05:10:38 -05:00
|
|
|
#[salsa::interned]
|
2019-11-20 08:39:58 -06:00
|
|
|
fn intern_type_alias(&self, loc: crate::TypeAliasLoc) -> crate::TypeAliasId;
|
2019-11-15 10:14:50 -06:00
|
|
|
#[salsa::interned]
|
|
|
|
fn intern_impl(&self, loc: ItemLoc<ast::ImplBlock>) -> crate::ImplId;
|
2019-10-30 05:10:38 -05:00
|
|
|
}
|
2019-10-30 08:12:55 -05:00
|
|
|
|
|
|
|
#[salsa::query_group(DefDatabase2Storage)]
|
|
|
|
pub trait DefDatabase2: InternDatabase + AstDatabase {
|
|
|
|
#[salsa::invoke(RawItems::raw_items_with_source_map_query)]
|
|
|
|
fn raw_items_with_source_map(
|
|
|
|
&self,
|
|
|
|
file_id: HirFileId,
|
|
|
|
) -> (Arc<RawItems>, Arc<ImportSourceMap>);
|
|
|
|
|
|
|
|
#[salsa::invoke(RawItems::raw_items_query)]
|
|
|
|
fn raw_items(&self, file_id: HirFileId) -> Arc<RawItems>;
|
2019-10-31 08:40:36 -05:00
|
|
|
|
2019-10-31 10:45:10 -05:00
|
|
|
#[salsa::invoke(CrateDefMap::crate_def_map_query)]
|
|
|
|
fn crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>;
|
|
|
|
|
2019-10-31 08:40:36 -05:00
|
|
|
#[salsa::invoke(StructData::struct_data_query)]
|
2019-11-09 06:34:00 -06:00
|
|
|
fn struct_data(&self, id: StructOrUnionId) -> Arc<StructData>;
|
2019-10-31 10:45:10 -05:00
|
|
|
|
2019-10-31 08:40:36 -05:00
|
|
|
#[salsa::invoke(EnumData::enum_data_query)]
|
|
|
|
fn enum_data(&self, e: EnumId) -> Arc<EnumData>;
|
2019-11-14 08:37:22 -06:00
|
|
|
|
2019-11-15 12:28:00 -06:00
|
|
|
#[salsa::invoke(ImplData::impl_data_query)]
|
|
|
|
fn impl_data(&self, e: ImplId) -> Arc<ImplData>;
|
|
|
|
|
2019-11-20 05:22:06 -06:00
|
|
|
#[salsa::invoke(TraitData::trait_data_query)]
|
|
|
|
fn trait_data(&self, e: TraitId) -> Arc<TraitData>;
|
|
|
|
|
2019-11-22 03:57:40 -06:00
|
|
|
#[salsa::invoke(TypeAliasData::type_alias_data_query)]
|
|
|
|
fn type_alias_data(&self, e: TypeAliasId) -> Arc<TypeAliasData>;
|
|
|
|
|
2019-11-22 08:10:51 -06:00
|
|
|
#[salsa::invoke(FunctionData::fn_data_query)]
|
|
|
|
fn function_data(&self, func: FunctionId) -> Arc<FunctionData>;
|
|
|
|
|
2019-11-22 09:46:39 -06:00
|
|
|
#[salsa::invoke(ConstData::const_data_query)]
|
|
|
|
fn const_data(&self, konst: ConstId) -> Arc<ConstData>;
|
|
|
|
|
|
|
|
#[salsa::invoke(ConstData::static_data_query)]
|
|
|
|
fn static_data(&self, konst: StaticId) -> Arc<ConstData>;
|
|
|
|
|
2019-11-14 08:37:22 -06:00
|
|
|
#[salsa::invoke(Body::body_with_source_map_query)]
|
|
|
|
fn body_with_source_map(&self, def: DefWithBodyId) -> (Arc<Body>, Arc<BodySourceMap>);
|
|
|
|
|
|
|
|
#[salsa::invoke(Body::body_query)]
|
|
|
|
fn body(&self, def: DefWithBodyId) -> Arc<Body>;
|
|
|
|
|
|
|
|
#[salsa::invoke(ExprScopes::expr_scopes_query)]
|
|
|
|
fn expr_scopes(&self, def: DefWithBodyId) -> Arc<ExprScopes>;
|
2019-11-20 11:33:18 -06:00
|
|
|
|
|
|
|
#[salsa::invoke(GenericParams::generic_params_query)]
|
|
|
|
fn generic_params(&self, def: GenericDefId) -> Arc<GenericParams>;
|
2019-10-30 08:12:55 -05:00
|
|
|
}
|