2019-10-30 10:10:38 +00:00
|
|
|
//! Defines database & queries for name resolution.
|
2019-10-30 13:12:55 +00:00
|
|
|
use std::sync::Arc;
|
2019-10-30 10:10:38 +00:00
|
|
|
|
2019-10-30 13:12:55 +00:00
|
|
|
use hir_expand::{db::AstDatabase, HirFileId};
|
2019-10-31 15:45:10 +00:00
|
|
|
use ra_db::{salsa, CrateId, SourceDatabase};
|
2019-10-30 10:10:38 +00:00
|
|
|
use ra_syntax::ast;
|
|
|
|
|
2019-10-31 13:40:36 +00:00
|
|
|
use crate::{
|
|
|
|
adt::{EnumData, StructData},
|
2019-10-31 15:45:10 +00:00
|
|
|
nameres::{
|
|
|
|
raw::{ImportSourceMap, RawItems},
|
|
|
|
CrateDefMap,
|
|
|
|
},
|
2019-11-09 12:34:00 +00:00
|
|
|
EnumId, StructOrUnionId,
|
2019-10-31 13:40:36 +00:00
|
|
|
};
|
2019-10-30 13:12:55 +00:00
|
|
|
|
2019-10-30 10:10:38 +00:00
|
|
|
#[salsa::query_group(InternDatabaseStorage)]
|
|
|
|
pub trait InternDatabase: SourceDatabase {
|
|
|
|
#[salsa::interned]
|
|
|
|
fn intern_function(&self, loc: crate::ItemLoc<ast::FnDef>) -> crate::FunctionId;
|
|
|
|
#[salsa::interned]
|
2019-11-09 12:34:00 +00:00
|
|
|
fn intern_struct_or_union(&self, loc: crate::ItemLoc<ast::StructDef>)
|
|
|
|
-> crate::StructOrUnionId;
|
2019-10-30 13:12:55 +00:00
|
|
|
#[salsa::interned]
|
2019-10-30 10:10:38 +00:00
|
|
|
fn intern_enum(&self, loc: crate::ItemLoc<ast::EnumDef>) -> crate::EnumId;
|
|
|
|
#[salsa::interned]
|
|
|
|
fn intern_const(&self, loc: crate::ItemLoc<ast::ConstDef>) -> crate::ConstId;
|
|
|
|
#[salsa::interned]
|
|
|
|
fn intern_static(&self, loc: crate::ItemLoc<ast::StaticDef>) -> crate::StaticId;
|
|
|
|
#[salsa::interned]
|
|
|
|
fn intern_trait(&self, loc: crate::ItemLoc<ast::TraitDef>) -> crate::TraitId;
|
|
|
|
#[salsa::interned]
|
|
|
|
fn intern_type_alias(&self, loc: crate::ItemLoc<ast::TypeAliasDef>) -> crate::TypeAliasId;
|
|
|
|
}
|
2019-10-30 13:12:55 +00: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 13:40:36 +00:00
|
|
|
|
2019-10-31 15:45:10 +00:00
|
|
|
#[salsa::invoke(CrateDefMap::crate_def_map_query)]
|
|
|
|
fn crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>;
|
|
|
|
|
2019-10-31 13:40:36 +00:00
|
|
|
#[salsa::invoke(StructData::struct_data_query)]
|
2019-11-09 12:34:00 +00:00
|
|
|
fn struct_data(&self, id: StructOrUnionId) -> Arc<StructData>;
|
2019-10-31 15:45:10 +00:00
|
|
|
|
2019-10-31 13:40:36 +00:00
|
|
|
#[salsa::invoke(EnumData::enum_data_query)]
|
|
|
|
fn enum_data(&self, e: EnumId) -> Arc<EnumData>;
|
2019-10-30 13:12:55 +00:00
|
|
|
}
|