rust/crates/ra_hir/src/db.rs

114 lines
3.5 KiB
Rust
Raw Normal View History

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