rust/crates/ra_hir/src/db.rs

127 lines
3.8 KiB
Rust
Raw Normal View History

2018-11-27 18:42:26 -06:00
use std::sync::Arc;
use ra_syntax::{SyntaxNode, TreeArc, SourceFile};
2019-01-15 11:54:18 -06:00
use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase};
2018-11-27 18:42:26 -06:00
use crate::{
DefLoc, DefId, MacroCallLoc, MacroCallId, Name, HirFileId,
SourceFileItems, SourceItemId, Crate,
2018-11-27 18:42:26 -06:00
query_definitions,
2019-01-05 18:00:34 -06:00
FnSignature, FnScopes,
2019-01-01 15:37:36 -06:00
macros::MacroExpansion,
2019-01-06 10:58:10 -06:00
module_tree::{ModuleId, ModuleTree},
2019-01-06 08:33:27 -06:00
nameres::{ItemMap, InputModuleItems},
ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks},
adt::{StructData, EnumData, EnumVariantData},
impl_block::ModuleImplBlocks,
2018-11-27 18:42:26 -06:00
};
salsa::query_group! {
2018-11-27 19:09:44 -06:00
pub trait HirDatabase: SyntaxDatabase
2018-11-27 18:42:26 -06:00
+ AsRef<LocationIntener<DefLoc, DefId>>
2019-01-01 09:12:31 -06:00
+ AsRef<LocationIntener<MacroCallLoc, MacroCallId>>
2018-11-27 18:42:26 -06:00
{
fn hir_source_file(file_id: HirFileId) -> TreeArc<SourceFile> {
2019-01-01 14:21:16 -06:00
type HirSourceFileQuery;
2019-01-02 03:49:09 -06:00
use fn HirFileId::hir_source_file;
2019-01-01 11:59:00 -06:00
}
2019-01-01 09:12:31 -06:00
fn expand_macro_invocation(invoc: MacroCallId) -> Option<Arc<MacroExpansion>> {
type ExpandMacroCallQuery;
2019-01-01 09:11:04 -06:00
use fn crate::macros::expand_macro_invocation;
}
2019-01-15 10:04:49 -06:00
fn fn_scopes(def_id: DefId) -> Arc<FnScopes> {
2018-11-27 18:42:26 -06:00
type FnScopesQuery;
use fn query_definitions::fn_scopes;
}
2019-01-15 09:43:25 -06:00
fn struct_data(def_id: DefId) -> Arc<StructData> {
type StructDataQuery;
2019-01-08 06:38:29 -06:00
use fn crate::adt::StructData::struct_data_query;
}
2019-01-15 09:43:25 -06:00
fn enum_data(def_id: DefId) -> Arc<EnumData> {
type EnumDataQuery;
2019-01-08 06:38:29 -06:00
use fn crate::adt::EnumData::enum_data_query;
}
2019-01-15 09:43:25 -06:00
fn enum_variant_data(def_id: DefId) -> Arc<EnumVariantData> {
type EnumVariantDataQuery;
use fn crate::adt::EnumVariantData::enum_variant_data_query;
}
2019-01-15 11:54:18 -06:00
fn infer(def_id: DefId) -> Arc<InferenceResult> {
2018-12-20 14:56:28 -06:00
type InferQuery;
use fn crate::ty::infer;
2018-12-20 14:56:28 -06:00
}
2019-01-15 11:43:37 -06:00
fn type_for_def(def_id: DefId) -> Ty {
type TypeForDefQuery;
use fn crate::ty::type_for_def;
}
2019-01-15 11:43:37 -06:00
fn type_for_field(def_id: DefId, field: Name) -> Option<Ty> {
type TypeForFieldQuery;
use fn crate::ty::type_for_field;
}
2019-01-01 14:21:16 -06:00
fn file_items(file_id: HirFileId) -> Arc<SourceFileItems> {
2018-11-27 18:42:26 -06:00
type SourceFileItemsQuery;
use fn query_definitions::file_items;
}
fn file_item(source_item_id: SourceItemId) -> TreeArc<SyntaxNode> {
2018-11-27 18:42:26 -06:00
type FileItemQuery;
use fn query_definitions::file_item;
}
fn submodules(source: SourceItemId) -> Arc<Vec<crate::module_tree::Submodule>> {
2018-11-27 18:42:26 -06:00
type SubmodulesQuery;
use fn crate::module_tree::Submodule::submodules_query;
2018-11-27 18:42:26 -06:00
}
2019-01-15 09:13:11 -06:00
fn input_module_items(source_root_id: SourceRootId, module_id: ModuleId) -> Arc<InputModuleItems> {
2018-11-27 18:42:26 -06:00
type InputModuleItemsQuery;
use fn query_definitions::input_module_items;
}
2019-01-15 10:15:01 -06:00
fn item_map(source_root_id: SourceRootId) -> Arc<ItemMap> {
2018-11-27 18:42:26 -06:00
type ItemMapQuery;
use fn query_definitions::item_map;
}
fn module_tree(source_root_id: SourceRootId) -> Arc<ModuleTree> {
2018-11-27 18:42:26 -06:00
type ModuleTreeQuery;
2019-01-06 08:33:27 -06:00
use fn crate::module_tree::ModuleTree::module_tree_query;
2018-11-27 18:42:26 -06:00
}
2019-01-15 10:18:52 -06:00
fn impls_in_module(source_root_id: SourceRootId, module_id: ModuleId) -> Arc<ModuleImplBlocks> {
2019-01-04 12:52:07 -06:00
type ImplsInModuleQuery;
use fn crate::impl_block::impls_in_module;
}
2019-01-05 09:32:07 -06:00
2019-01-15 11:54:18 -06:00
fn impls_in_crate(krate: Crate) -> Arc<CrateImplBlocks> {
type ImplsInCrateQuery;
use fn crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query;
}
2019-01-15 10:01:59 -06:00
fn body_hir(def_id: DefId) -> Arc<crate::expr::Body> {
2019-01-05 09:32:07 -06:00
type BodyHirQuery;
use fn crate::expr::body_hir;
}
2019-01-15 10:01:59 -06:00
fn body_syntax_mapping(def_id: DefId) -> Arc<crate::expr::BodySyntaxMapping> {
2019-01-05 09:32:07 -06:00
type BodySyntaxMappingQuery;
use fn crate::expr::body_syntax_mapping;
}
2019-01-05 18:00:34 -06:00
fn fn_signature(def_id: DefId) -> Arc<FnSignature> {
type FnSignatureQuery;
2019-01-08 11:11:13 -06:00
use fn crate::FnSignature::fn_signature_query;
2019-01-05 18:00:34 -06:00
}
2018-11-27 18:42:26 -06:00
}
}