mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Get rid of DefDatabase2
This commit is contained in:
parent
958862093e
commit
fc1e543f7a
23 changed files with 123 additions and 135 deletions
|
@ -9,7 +9,7 @@ use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath
|
||||||
ra_db::SourceDatabaseStorage,
|
ra_db::SourceDatabaseStorage,
|
||||||
hir::db::InternDatabaseStorage,
|
hir::db::InternDatabaseStorage,
|
||||||
hir::db::AstDatabaseStorage,
|
hir::db::AstDatabaseStorage,
|
||||||
hir::db::DefDatabase2Storage,
|
hir::db::DefDatabaseStorage,
|
||||||
hir::db::HirDatabaseStorage
|
hir::db::HirDatabaseStorage
|
||||||
)]
|
)]
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
|
@ -17,7 +17,7 @@ use crate::{
|
||||||
|
|
||||||
pub use hir_def::db::{
|
pub use hir_def::db::{
|
||||||
BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery,
|
BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery,
|
||||||
DefDatabase2, DefDatabase2Storage, DocumentationQuery, EnumDataQuery, ExprScopesQuery,
|
DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, ExprScopesQuery,
|
||||||
FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, InternDatabaseStorage,
|
FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, InternDatabaseStorage,
|
||||||
LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, RawItemsWithSourceMapQuery,
|
LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, RawItemsWithSourceMapQuery,
|
||||||
StaticDataQuery, StructDataQuery, TraitDataQuery, TypeAliasDataQuery,
|
StaticDataQuery, StructDataQuery, TraitDataQuery, TypeAliasDataQuery,
|
||||||
|
@ -27,8 +27,6 @@ pub use hir_expand::db::{
|
||||||
ParseMacroQuery,
|
ParseMacroQuery,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use DefDatabase2 as DefDatabase;
|
|
||||||
|
|
||||||
#[salsa::query_group(HirDatabaseStorage)]
|
#[salsa::query_group(HirDatabaseStorage)]
|
||||||
#[salsa::requires(salsa::Database)]
|
#[salsa::requires(salsa::Database)]
|
||||||
pub trait HirDatabase: DefDatabase + AstDatabase {
|
pub trait HirDatabase: DefDatabase + AstDatabase {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::{panic, sync::Arc};
|
use std::{panic, sync::Arc};
|
||||||
|
|
||||||
use hir_def::{db::DefDatabase2, ModuleId};
|
use hir_def::{db::DefDatabase, ModuleId};
|
||||||
use hir_expand::diagnostics::DiagnosticSink;
|
use hir_expand::diagnostics::DiagnosticSink;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase};
|
use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase};
|
||||||
|
@ -14,7 +14,7 @@ use crate::{db, debug::HirDebugHelper};
|
||||||
ra_db::SourceDatabaseStorage,
|
ra_db::SourceDatabaseStorage,
|
||||||
db::InternDatabaseStorage,
|
db::InternDatabaseStorage,
|
||||||
db::AstDatabaseStorage,
|
db::AstDatabaseStorage,
|
||||||
db::DefDatabase2Storage,
|
db::DefDatabaseStorage,
|
||||||
db::HirDatabaseStorage
|
db::HirDatabaseStorage
|
||||||
)]
|
)]
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
|
@ -11,7 +11,7 @@ use ra_arena::{map::ArenaMap, Arena};
|
||||||
use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
|
use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase2, trace::Trace, type_ref::TypeRef, AstItemDef, EnumId, HasChildSource,
|
db::DefDatabase, trace::Trace, type_ref::TypeRef, AstItemDef, EnumId, HasChildSource,
|
||||||
LocalEnumVariantId, LocalStructFieldId, StructOrUnionId, VariantId,
|
LocalEnumVariantId, LocalStructFieldId, StructOrUnionId, VariantId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,10 +49,7 @@ pub struct StructFieldData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StructData {
|
impl StructData {
|
||||||
pub(crate) fn struct_data_query(
|
pub(crate) fn struct_data_query(db: &impl DefDatabase, id: StructOrUnionId) -> Arc<StructData> {
|
||||||
db: &impl DefDatabase2,
|
|
||||||
id: StructOrUnionId,
|
|
||||||
) -> Arc<StructData> {
|
|
||||||
let src = id.source(db);
|
let src = id.source(db);
|
||||||
let name = src.value.name().map(|n| n.as_name());
|
let name = src.value.name().map(|n| n.as_name());
|
||||||
let variant_data = VariantData::new(src.value.kind());
|
let variant_data = VariantData::new(src.value.kind());
|
||||||
|
@ -62,7 +59,7 @@ impl StructData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EnumData {
|
impl EnumData {
|
||||||
pub(crate) fn enum_data_query(db: &impl DefDatabase2, e: EnumId) -> Arc<EnumData> {
|
pub(crate) fn enum_data_query(db: &impl DefDatabase, e: EnumId) -> Arc<EnumData> {
|
||||||
let src = e.source(db);
|
let src = e.source(db);
|
||||||
let name = src.value.name().map(|n| n.as_name());
|
let name = src.value.name().map(|n| n.as_name());
|
||||||
let mut trace = Trace::new_for_arena();
|
let mut trace = Trace::new_for_arena();
|
||||||
|
@ -79,7 +76,7 @@ impl EnumData {
|
||||||
impl HasChildSource for EnumId {
|
impl HasChildSource for EnumId {
|
||||||
type ChildId = LocalEnumVariantId;
|
type ChildId = LocalEnumVariantId;
|
||||||
type Value = ast::EnumVariant;
|
type Value = ast::EnumVariant;
|
||||||
fn child_source(&self, db: &impl DefDatabase2) -> Source<ArenaMap<Self::ChildId, Self::Value>> {
|
fn child_source(&self, db: &impl DefDatabase) -> Source<ArenaMap<Self::ChildId, Self::Value>> {
|
||||||
let src = self.source(db);
|
let src = self.source(db);
|
||||||
let mut trace = Trace::new_for_map();
|
let mut trace = Trace::new_for_map();
|
||||||
lower_enum(&mut trace, &src.value);
|
lower_enum(&mut trace, &src.value);
|
||||||
|
@ -124,7 +121,7 @@ impl HasChildSource for VariantId {
|
||||||
type ChildId = LocalStructFieldId;
|
type ChildId = LocalStructFieldId;
|
||||||
type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>;
|
type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>;
|
||||||
|
|
||||||
fn child_source(&self, db: &impl DefDatabase2) -> Source<ArenaMap<Self::ChildId, Self::Value>> {
|
fn child_source(&self, db: &impl DefDatabase) -> Source<ArenaMap<Self::ChildId, Self::Value>> {
|
||||||
let src = match self {
|
let src = match self {
|
||||||
VariantId::EnumVariantId(it) => {
|
VariantId::EnumVariantId(it) => {
|
||||||
// I don't really like the fact that we call into parent source
|
// I don't really like the fact that we call into parent source
|
||||||
|
|
|
@ -12,7 +12,7 @@ use ra_syntax::{
|
||||||
use tt::Subtree;
|
use tt::Subtree;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase2, path::Path, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup,
|
db::DefDatabase, path::Path, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
||||||
|
@ -32,7 +32,7 @@ impl ops::Deref for Attrs {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Attrs {
|
impl Attrs {
|
||||||
pub(crate) fn attrs_query(db: &impl DefDatabase2, def: AttrDefId) -> Attrs {
|
pub(crate) fn attrs_query(db: &impl DefDatabase, def: AttrDefId) -> Attrs {
|
||||||
match def {
|
match def {
|
||||||
AttrDefId::ModuleId(module) => {
|
AttrDefId::ModuleId(module) => {
|
||||||
let def_map = db.crate_def_map(module.krate);
|
let def_map = db.crate_def_map(module.krate);
|
||||||
|
@ -162,7 +162,7 @@ impl Attr {
|
||||||
fn attrs_from_ast<D, N>(src: AstId<N>, db: &D) -> Attrs
|
fn attrs_from_ast<D, N>(src: AstId<N>, db: &D) -> Attrs
|
||||||
where
|
where
|
||||||
N: ast::AttrsOwner,
|
N: ast::AttrsOwner,
|
||||||
D: DefDatabase2,
|
D: DefDatabase,
|
||||||
{
|
{
|
||||||
let hygiene = Hygiene::new(db, src.file_id());
|
let hygiene = Hygiene::new(db, src.file_id());
|
||||||
Attr::from_attrs_owner(&src.to_node(db), &hygiene)
|
Attr::from_attrs_owner(&src.to_node(db), &hygiene)
|
||||||
|
@ -172,7 +172,7 @@ fn attrs_from_loc<T, D>(node: T, db: &D) -> Attrs
|
||||||
where
|
where
|
||||||
T: HasSource,
|
T: HasSource,
|
||||||
T::Value: ast::AttrsOwner,
|
T::Value: ast::AttrsOwner,
|
||||||
D: DefDatabase2,
|
D: DefDatabase,
|
||||||
{
|
{
|
||||||
let src = node.source(db);
|
let src = node.source(db);
|
||||||
let hygiene = Hygiene::new(db, src.file_id);
|
let hygiene = Hygiene::new(db, src.file_id);
|
||||||
|
|
|
@ -13,7 +13,7 @@ use ra_syntax::{ast, AstNode, AstPtr};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase2,
|
db::DefDatabase,
|
||||||
expr::{Expr, ExprId, Pat, PatId},
|
expr::{Expr, ExprId, Pat, PatId},
|
||||||
nameres::CrateDefMap,
|
nameres::CrateDefMap,
|
||||||
path::Path,
|
path::Path,
|
||||||
|
@ -28,7 +28,7 @@ pub struct Expander {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Expander {
|
impl Expander {
|
||||||
pub fn new(db: &impl DefDatabase2, current_file_id: HirFileId, module: ModuleId) -> Expander {
|
pub fn new(db: &impl DefDatabase, current_file_id: HirFileId, module: ModuleId) -> Expander {
|
||||||
let crate_def_map = db.crate_def_map(module.krate);
|
let crate_def_map = db.crate_def_map(module.krate);
|
||||||
let hygiene = Hygiene::new(db, current_file_id);
|
let hygiene = Hygiene::new(db, current_file_id);
|
||||||
Expander { crate_def_map, current_file_id, hygiene, module }
|
Expander { crate_def_map, current_file_id, hygiene, module }
|
||||||
|
@ -36,7 +36,7 @@ impl Expander {
|
||||||
|
|
||||||
fn enter_expand(
|
fn enter_expand(
|
||||||
&mut self,
|
&mut self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
macro_call: ast::MacroCall,
|
macro_call: ast::MacroCall,
|
||||||
) -> Option<(Mark, ast::Expr)> {
|
) -> Option<(Mark, ast::Expr)> {
|
||||||
let ast_id = AstId::new(
|
let ast_id = AstId::new(
|
||||||
|
@ -67,7 +67,7 @@ impl Expander {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exit(&mut self, db: &impl DefDatabase2, mark: Mark) {
|
fn exit(&mut self, db: &impl DefDatabase, mark: Mark) {
|
||||||
self.hygiene = Hygiene::new(db, mark.file_id);
|
self.hygiene = Hygiene::new(db, mark.file_id);
|
||||||
self.current_file_id = mark.file_id;
|
self.current_file_id = mark.file_id;
|
||||||
std::mem::forget(mark);
|
std::mem::forget(mark);
|
||||||
|
@ -81,7 +81,7 @@ impl Expander {
|
||||||
Path::from_src(path, &self.hygiene)
|
Path::from_src(path, &self.hygiene)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option<MacroDefId> {
|
fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
|
||||||
self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros()
|
self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ pub struct BodySourceMap {
|
||||||
|
|
||||||
impl Body {
|
impl Body {
|
||||||
pub(crate) fn body_with_source_map_query(
|
pub(crate) fn body_with_source_map_query(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
def: DefWithBodyId,
|
def: DefWithBodyId,
|
||||||
) -> (Arc<Body>, Arc<BodySourceMap>) {
|
) -> (Arc<Body>, Arc<BodySourceMap>) {
|
||||||
let mut params = None;
|
let mut params = None;
|
||||||
|
@ -169,12 +169,12 @@ impl Body {
|
||||||
(Arc::new(body), Arc::new(source_map))
|
(Arc::new(body), Arc::new(source_map))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn body_query(db: &impl DefDatabase2, def: DefWithBodyId) -> Arc<Body> {
|
pub(crate) fn body_query(db: &impl DefDatabase, def: DefWithBodyId) -> Arc<Body> {
|
||||||
db.body_with_source_map(def).0
|
db.body_with_source_map(def).0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(
|
fn new(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
expander: Expander,
|
expander: Expander,
|
||||||
params: Option<ast::ParamList>,
|
params: Option<ast::ParamList>,
|
||||||
body: Option<ast::Expr>,
|
body: Option<ast::Expr>,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use test_utils::tested_by;
|
||||||
use crate::{
|
use crate::{
|
||||||
body::{Body, BodySourceMap, Expander, PatPtr},
|
body::{Body, BodySourceMap, Expander, PatPtr},
|
||||||
builtin_type::{BuiltinFloat, BuiltinInt},
|
builtin_type::{BuiltinFloat, BuiltinInt},
|
||||||
db::DefDatabase2,
|
db::DefDatabase,
|
||||||
expr::{
|
expr::{
|
||||||
ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp,
|
ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp,
|
||||||
MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement,
|
MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement,
|
||||||
|
@ -28,7 +28,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(super) fn lower(
|
pub(super) fn lower(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
expander: Expander,
|
expander: Expander,
|
||||||
params: Option<ast::ParamList>,
|
params: Option<ast::ParamList>,
|
||||||
body: Option<ast::Expr>,
|
body: Option<ast::Expr>,
|
||||||
|
@ -57,7 +57,7 @@ struct ExprCollector<DB> {
|
||||||
|
|
||||||
impl<'a, DB> ExprCollector<&'a DB>
|
impl<'a, DB> ExprCollector<&'a DB>
|
||||||
where
|
where
|
||||||
DB: DefDatabase2,
|
DB: DefDatabase,
|
||||||
{
|
{
|
||||||
fn collect(
|
fn collect(
|
||||||
mut self,
|
mut self,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
body::Body,
|
body::Body,
|
||||||
db::DefDatabase2,
|
db::DefDatabase,
|
||||||
expr::{Expr, ExprId, Pat, PatId, Statement},
|
expr::{Expr, ExprId, Pat, PatId, Statement},
|
||||||
DefWithBodyId,
|
DefWithBodyId,
|
||||||
};
|
};
|
||||||
|
@ -45,7 +45,7 @@ pub struct ScopeData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExprScopes {
|
impl ExprScopes {
|
||||||
pub(crate) fn expr_scopes_query(db: &impl DefDatabase2, def: DefWithBodyId) -> Arc<ExprScopes> {
|
pub(crate) fn expr_scopes_query(db: &impl DefDatabase, def: DefWithBodyId) -> Arc<ExprScopes> {
|
||||||
let body = db.body(def);
|
let body = db.body(def);
|
||||||
Arc::new(ExprScopes::new(&*body))
|
Arc::new(ExprScopes::new(&*body))
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ mod tests {
|
||||||
use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
|
use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
|
||||||
use test_utils::{assert_eq_text, covers, extract_offset};
|
use test_utils::{assert_eq_text, covers, extract_offset};
|
||||||
|
|
||||||
use crate::{db::DefDatabase2, test_db::TestDB, FunctionId, ModuleDefId};
|
use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};
|
||||||
|
|
||||||
fn find_function(db: &TestDB, file_id: FileId) -> FunctionId {
|
fn find_function(db: &TestDB, file_id: FileId) -> FunctionId {
|
||||||
let krate = db.test_crate();
|
let krate = db.test_crate();
|
||||||
|
|
|
@ -9,7 +9,7 @@ use hir_expand::{
|
||||||
use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
|
use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase2,
|
db::DefDatabase,
|
||||||
type_ref::{Mutability, TypeRef},
|
type_ref::{Mutability, TypeRef},
|
||||||
AssocItemId, AstItemDef, ConstId, ConstLoc, ContainerId, FunctionId, FunctionLoc, HasSource,
|
AssocItemId, AstItemDef, ConstId, ConstLoc, ContainerId, FunctionId, FunctionLoc, HasSource,
|
||||||
ImplId, Intern, Lookup, StaticId, TraitId, TypeAliasId, TypeAliasLoc,
|
ImplId, Intern, Lookup, StaticId, TraitId, TypeAliasId, TypeAliasLoc,
|
||||||
|
@ -26,7 +26,7 @@ pub struct FunctionData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FunctionData {
|
impl FunctionData {
|
||||||
pub(crate) fn fn_data_query(db: &impl DefDatabase2, func: FunctionId) -> Arc<FunctionData> {
|
pub(crate) fn fn_data_query(db: &impl DefDatabase, func: FunctionId) -> Arc<FunctionData> {
|
||||||
let src = func.lookup(db).source(db);
|
let src = func.lookup(db).source(db);
|
||||||
let name = src.value.name().map(|n| n.as_name()).unwrap_or_else(Name::missing);
|
let name = src.value.name().map(|n| n.as_name()).unwrap_or_else(Name::missing);
|
||||||
let mut params = Vec::new();
|
let mut params = Vec::new();
|
||||||
|
@ -74,7 +74,7 @@ pub struct TypeAliasData {
|
||||||
|
|
||||||
impl TypeAliasData {
|
impl TypeAliasData {
|
||||||
pub(crate) fn type_alias_data_query(
|
pub(crate) fn type_alias_data_query(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
typ: TypeAliasId,
|
typ: TypeAliasId,
|
||||||
) -> Arc<TypeAliasData> {
|
) -> Arc<TypeAliasData> {
|
||||||
let node = typ.lookup(db).source(db).value;
|
let node = typ.lookup(db).source(db).value;
|
||||||
|
@ -92,7 +92,7 @@ pub struct TraitData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TraitData {
|
impl TraitData {
|
||||||
pub(crate) fn trait_data_query(db: &impl DefDatabase2, tr: TraitId) -> Arc<TraitData> {
|
pub(crate) fn trait_data_query(db: &impl DefDatabase, tr: TraitId) -> Arc<TraitData> {
|
||||||
let src = tr.source(db);
|
let src = tr.source(db);
|
||||||
let name = src.value.name().map(|n| n.as_name());
|
let name = src.value.name().map(|n| n.as_name());
|
||||||
let auto = src.value.is_auto();
|
let auto = src.value.is_auto();
|
||||||
|
@ -144,7 +144,7 @@ pub struct ImplData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImplData {
|
impl ImplData {
|
||||||
pub(crate) fn impl_data_query(db: &impl DefDatabase2, id: ImplId) -> Arc<ImplData> {
|
pub(crate) fn impl_data_query(db: &impl DefDatabase, id: ImplId) -> Arc<ImplData> {
|
||||||
let src = id.source(db);
|
let src = id.source(db);
|
||||||
let items = db.ast_id_map(src.file_id);
|
let items = db.ast_id_map(src.file_id);
|
||||||
|
|
||||||
|
@ -198,12 +198,12 @@ pub struct ConstData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConstData {
|
impl ConstData {
|
||||||
pub(crate) fn const_data_query(db: &impl DefDatabase2, konst: ConstId) -> Arc<ConstData> {
|
pub(crate) fn const_data_query(db: &impl DefDatabase, konst: ConstId) -> Arc<ConstData> {
|
||||||
let node = konst.lookup(db).source(db).value;
|
let node = konst.lookup(db).source(db).value;
|
||||||
const_data_for(&node)
|
const_data_for(&node)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn static_data_query(db: &impl DefDatabase2, konst: StaticId) -> Arc<ConstData> {
|
pub(crate) fn static_data_query(db: &impl DefDatabase, konst: StaticId) -> Arc<ConstData> {
|
||||||
let node = konst.source(db).value;
|
let node = konst.source(db).value;
|
||||||
const_data_for(&node)
|
const_data_for(&node)
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ pub trait InternDatabase: SourceDatabase {
|
||||||
fn intern_impl(&self, loc: ItemLoc<ast::ImplBlock>) -> crate::ImplId;
|
fn intern_impl(&self, loc: ItemLoc<ast::ImplBlock>) -> crate::ImplId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::query_group(DefDatabase2Storage)]
|
#[salsa::query_group(DefDatabaseStorage)]
|
||||||
pub trait DefDatabase2: InternDatabase + AstDatabase {
|
pub trait DefDatabase: InternDatabase + AstDatabase {
|
||||||
#[salsa::invoke(RawItems::raw_items_with_source_map_query)]
|
#[salsa::invoke(RawItems::raw_items_with_source_map_query)]
|
||||||
fn raw_items_with_source_map(
|
fn raw_items_with_source_map(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||||
use hir_expand::either::Either;
|
use hir_expand::either::Either;
|
||||||
use ra_syntax::ast;
|
use ra_syntax::ast;
|
||||||
|
|
||||||
use crate::{db::DefDatabase2, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup};
|
use crate::{db::DefDatabase, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup};
|
||||||
|
|
||||||
/// Holds documentation
|
/// Holds documentation
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
@ -27,7 +27,7 @@ impl Documentation {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn documentation_query(
|
pub(crate) fn documentation_query(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
def: AttrDefId,
|
def: AttrDefId,
|
||||||
) -> Option<Documentation> {
|
) -> Option<Documentation> {
|
||||||
match def {
|
match def {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use hir_expand::name::{self, AsName, Name};
|
||||||
use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner};
|
use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase2,
|
db::DefDatabase,
|
||||||
type_ref::{TypeBound, TypeRef},
|
type_ref::{TypeBound, TypeRef},
|
||||||
AdtId, AstItemDef, ContainerId, GenericDefId, HasSource, Lookup,
|
AdtId, AstItemDef, ContainerId, GenericDefId, HasSource, Lookup,
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,7 @@ pub struct WherePredicate {
|
||||||
|
|
||||||
impl GenericParams {
|
impl GenericParams {
|
||||||
pub(crate) fn generic_params_query(
|
pub(crate) fn generic_params_query(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
def: GenericDefId,
|
def: GenericDefId,
|
||||||
) -> Arc<GenericParams> {
|
) -> Arc<GenericParams> {
|
||||||
let parent_generics = parent_generic_def(db, def).map(|it| db.generic_params(it));
|
let parent_generics = parent_generic_def(db, def).map(|it| db.generic_params(it));
|
||||||
|
@ -50,7 +50,7 @@ impl GenericParams {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(
|
fn new(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
def: GenericDefId,
|
def: GenericDefId,
|
||||||
parent_params: Option<Arc<GenericParams>>,
|
parent_params: Option<Arc<GenericParams>>,
|
||||||
) -> GenericParams {
|
) -> GenericParams {
|
||||||
|
@ -168,7 +168,7 @@ impl GenericParams {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_generic_def(db: &impl DefDatabase2, def: GenericDefId) -> Option<GenericDefId> {
|
fn parent_generic_def(db: &impl DefDatabase, def: GenericDefId) -> Option<GenericDefId> {
|
||||||
let container = match def {
|
let container = match def {
|
||||||
GenericDefId::FunctionId(it) => it.lookup(db).container,
|
GenericDefId::FunctionId(it) => it.lookup(db).container,
|
||||||
GenericDefId::TypeAliasId(it) => it.lookup(db).container,
|
GenericDefId::TypeAliasId(it) => it.lookup(db).container,
|
||||||
|
|
|
@ -8,7 +8,7 @@ use ra_syntax::SmolStr;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase2, AdtId, AttrDefId, CrateId, EnumId, FunctionId, ImplId, ModuleDefId, ModuleId,
|
db::DefDatabase, AdtId, AttrDefId, CrateId, EnumId, FunctionId, ImplId, ModuleDefId, ModuleId,
|
||||||
StaticId, StructId, TraitId,
|
StaticId, StructId, TraitId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ impl LangItems {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Salsa query. This will look for lang items in a specific crate.
|
/// Salsa query. This will look for lang items in a specific crate.
|
||||||
pub(crate) fn crate_lang_items_query(db: &impl DefDatabase2, krate: CrateId) -> Arc<LangItems> {
|
pub(crate) fn crate_lang_items_query(db: &impl DefDatabase, krate: CrateId) -> Arc<LangItems> {
|
||||||
let mut lang_items = LangItems::default();
|
let mut lang_items = LangItems::default();
|
||||||
|
|
||||||
let crate_def_map = db.crate_def_map(krate);
|
let crate_def_map = db.crate_def_map(krate);
|
||||||
|
@ -47,7 +47,7 @@ impl LangItems {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn module_lang_items_query(
|
pub(crate) fn module_lang_items_query(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
module: ModuleId,
|
module: ModuleId,
|
||||||
) -> Option<Arc<LangItems>> {
|
) -> Option<Arc<LangItems>> {
|
||||||
let mut lang_items = LangItems::default();
|
let mut lang_items = LangItems::default();
|
||||||
|
@ -62,7 +62,7 @@ impl LangItems {
|
||||||
/// Salsa query. Look for a lang item, starting from the specified crate and recursively
|
/// Salsa query. Look for a lang item, starting from the specified crate and recursively
|
||||||
/// traversing its dependencies.
|
/// traversing its dependencies.
|
||||||
pub(crate) fn lang_item_query(
|
pub(crate) fn lang_item_query(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
start_crate: CrateId,
|
start_crate: CrateId,
|
||||||
item: SmolStr,
|
item: SmolStr,
|
||||||
) -> Option<LangItemTarget> {
|
) -> Option<LangItemTarget> {
|
||||||
|
@ -76,7 +76,7 @@ impl LangItems {
|
||||||
.find_map(|dep| db.lang_item(dep.crate_id, item.clone()))
|
.find_map(|dep| db.lang_item(dep.crate_id, item.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_lang_items(&mut self, db: &impl DefDatabase2, module: ModuleId) {
|
fn collect_lang_items(&mut self, db: &impl DefDatabase, module: ModuleId) {
|
||||||
// Look for impl targets
|
// Look for impl targets
|
||||||
let def_map = db.crate_def_map(module.krate);
|
let def_map = db.crate_def_map(module.krate);
|
||||||
let module_data = &def_map[module.module_id];
|
let module_data = &def_map[module.module_id];
|
||||||
|
@ -106,7 +106,7 @@ impl LangItems {
|
||||||
|
|
||||||
fn collect_lang_item<T>(
|
fn collect_lang_item<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
item: T,
|
item: T,
|
||||||
constructor: fn(T) -> LangItemTarget,
|
constructor: fn(T) -> LangItemTarget,
|
||||||
) where
|
) where
|
||||||
|
|
|
@ -48,7 +48,7 @@ pub enum ModuleSource {
|
||||||
|
|
||||||
impl ModuleSource {
|
impl ModuleSource {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
db: &impl db::DefDatabase2,
|
db: &impl db::DefDatabase,
|
||||||
file_id: Option<FileId>,
|
file_id: Option<FileId>,
|
||||||
decl_id: Option<AstId<ast::Module>>,
|
decl_id: Option<AstId<ast::Module>>,
|
||||||
) -> ModuleSource {
|
) -> ModuleSource {
|
||||||
|
@ -67,10 +67,7 @@ impl ModuleSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: this methods do not belong here
|
// FIXME: this methods do not belong here
|
||||||
pub fn from_position(
|
pub fn from_position(db: &impl db::DefDatabase, position: ra_db::FilePosition) -> ModuleSource {
|
||||||
db: &impl db::DefDatabase2,
|
|
||||||
position: ra_db::FilePosition,
|
|
||||||
) -> ModuleSource {
|
|
||||||
let parse = db.parse(position.file_id);
|
let parse = db.parse(position.file_id);
|
||||||
match &ra_syntax::algo::find_node_at_offset::<ast::Module>(
|
match &ra_syntax::algo::find_node_at_offset::<ast::Module>(
|
||||||
parse.tree().syntax(),
|
parse.tree().syntax(),
|
||||||
|
@ -84,7 +81,7 @@ impl ModuleSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_child_node(db: &impl db::DefDatabase2, child: Source<&SyntaxNode>) -> ModuleSource {
|
pub fn from_child_node(db: &impl db::DefDatabase, child: Source<&SyntaxNode>) -> ModuleSource {
|
||||||
if let Some(m) =
|
if let Some(m) =
|
||||||
child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi())
|
child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi())
|
||||||
{
|
{
|
||||||
|
@ -96,7 +93,7 @@ impl ModuleSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_file_id(db: &impl db::DefDatabase2, file_id: FileId) -> ModuleSource {
|
pub fn from_file_id(db: &impl db::DefDatabase, file_id: FileId) -> ModuleSource {
|
||||||
let source_file = db.parse(file_id).tree();
|
let source_file = db.parse(file_id).tree();
|
||||||
ModuleSource::SourceFile(source_file)
|
ModuleSource::SourceFile(source_file)
|
||||||
}
|
}
|
||||||
|
@ -211,14 +208,14 @@ pub struct FunctionLoc {
|
||||||
|
|
||||||
impl Intern for FunctionLoc {
|
impl Intern for FunctionLoc {
|
||||||
type ID = FunctionId;
|
type ID = FunctionId;
|
||||||
fn intern(self, db: &impl db::DefDatabase2) -> FunctionId {
|
fn intern(self, db: &impl db::DefDatabase) -> FunctionId {
|
||||||
db.intern_function(self)
|
db.intern_function(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Lookup for FunctionId {
|
impl Lookup for FunctionId {
|
||||||
type Data = FunctionLoc;
|
type Data = FunctionLoc;
|
||||||
fn lookup(&self, db: &impl db::DefDatabase2) -> FunctionLoc {
|
fn lookup(&self, db: &impl db::DefDatabase) -> FunctionLoc {
|
||||||
db.lookup_intern_function(*self)
|
db.lookup_intern_function(*self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,14 +298,14 @@ pub struct ConstLoc {
|
||||||
|
|
||||||
impl Intern for ConstLoc {
|
impl Intern for ConstLoc {
|
||||||
type ID = ConstId;
|
type ID = ConstId;
|
||||||
fn intern(self, db: &impl db::DefDatabase2) -> ConstId {
|
fn intern(self, db: &impl db::DefDatabase) -> ConstId {
|
||||||
db.intern_const(self)
|
db.intern_const(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Lookup for ConstId {
|
impl Lookup for ConstId {
|
||||||
type Data = ConstLoc;
|
type Data = ConstLoc;
|
||||||
fn lookup(&self, db: &impl db::DefDatabase2) -> ConstLoc {
|
fn lookup(&self, db: &impl db::DefDatabase) -> ConstLoc {
|
||||||
db.lookup_intern_const(*self)
|
db.lookup_intern_const(*self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,14 +346,14 @@ pub struct TypeAliasLoc {
|
||||||
|
|
||||||
impl Intern for TypeAliasLoc {
|
impl Intern for TypeAliasLoc {
|
||||||
type ID = TypeAliasId;
|
type ID = TypeAliasId;
|
||||||
fn intern(self, db: &impl db::DefDatabase2) -> TypeAliasId {
|
fn intern(self, db: &impl db::DefDatabase) -> TypeAliasId {
|
||||||
db.intern_type_alias(self)
|
db.intern_type_alias(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Lookup for TypeAliasId {
|
impl Lookup for TypeAliasId {
|
||||||
type Data = TypeAliasLoc;
|
type Data = TypeAliasLoc;
|
||||||
fn lookup(&self, db: &impl db::DefDatabase2) -> TypeAliasLoc {
|
fn lookup(&self, db: &impl db::DefDatabase) -> TypeAliasLoc {
|
||||||
db.lookup_intern_type_alias(*self)
|
db.lookup_intern_type_alias(*self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -510,20 +507,20 @@ impl_froms!(
|
||||||
|
|
||||||
trait Intern {
|
trait Intern {
|
||||||
type ID;
|
type ID;
|
||||||
fn intern(self, db: &impl db::DefDatabase2) -> Self::ID;
|
fn intern(self, db: &impl db::DefDatabase) -> Self::ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Lookup {
|
pub trait Lookup {
|
||||||
type Data;
|
type Data;
|
||||||
fn lookup(&self, db: &impl db::DefDatabase2) -> Self::Data;
|
fn lookup(&self, db: &impl db::DefDatabase) -> Self::Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HasModule {
|
pub trait HasModule {
|
||||||
fn module(&self, db: &impl db::DefDatabase2) -> ModuleId;
|
fn module(&self, db: &impl db::DefDatabase) -> ModuleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasModule for FunctionLoc {
|
impl HasModule for FunctionLoc {
|
||||||
fn module(&self, db: &impl db::DefDatabase2) -> ModuleId {
|
fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
|
||||||
match self.container {
|
match self.container {
|
||||||
ContainerId::ModuleId(it) => it,
|
ContainerId::ModuleId(it) => it,
|
||||||
ContainerId::ImplId(it) => it.module(db),
|
ContainerId::ImplId(it) => it.module(db),
|
||||||
|
@ -533,7 +530,7 @@ impl HasModule for FunctionLoc {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasModule for TypeAliasLoc {
|
impl HasModule for TypeAliasLoc {
|
||||||
fn module(&self, db: &impl db::DefDatabase2) -> ModuleId {
|
fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
|
||||||
match self.container {
|
match self.container {
|
||||||
ContainerId::ModuleId(it) => it,
|
ContainerId::ModuleId(it) => it,
|
||||||
ContainerId::ImplId(it) => it.module(db),
|
ContainerId::ImplId(it) => it.module(db),
|
||||||
|
@ -543,7 +540,7 @@ impl HasModule for TypeAliasLoc {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasModule for ConstLoc {
|
impl HasModule for ConstLoc {
|
||||||
fn module(&self, db: &impl db::DefDatabase2) -> ModuleId {
|
fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
|
||||||
match self.container {
|
match self.container {
|
||||||
ContainerId::ModuleId(it) => it,
|
ContainerId::ModuleId(it) => it,
|
||||||
ContainerId::ImplId(it) => it.module(db),
|
ContainerId::ImplId(it) => it.module(db),
|
||||||
|
@ -554,13 +551,13 @@ impl HasModule for ConstLoc {
|
||||||
|
|
||||||
pub trait HasSource {
|
pub trait HasSource {
|
||||||
type Value;
|
type Value;
|
||||||
fn source(&self, db: &impl db::DefDatabase2) -> Source<Self::Value>;
|
fn source(&self, db: &impl db::DefDatabase) -> Source<Self::Value>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasSource for FunctionLoc {
|
impl HasSource for FunctionLoc {
|
||||||
type Value = ast::FnDef;
|
type Value = ast::FnDef;
|
||||||
|
|
||||||
fn source(&self, db: &impl db::DefDatabase2) -> Source<ast::FnDef> {
|
fn source(&self, db: &impl db::DefDatabase) -> Source<ast::FnDef> {
|
||||||
let node = self.ast_id.to_node(db);
|
let node = self.ast_id.to_node(db);
|
||||||
Source::new(self.ast_id.file_id(), node)
|
Source::new(self.ast_id.file_id(), node)
|
||||||
}
|
}
|
||||||
|
@ -569,7 +566,7 @@ impl HasSource for FunctionLoc {
|
||||||
impl HasSource for TypeAliasLoc {
|
impl HasSource for TypeAliasLoc {
|
||||||
type Value = ast::TypeAliasDef;
|
type Value = ast::TypeAliasDef;
|
||||||
|
|
||||||
fn source(&self, db: &impl db::DefDatabase2) -> Source<ast::TypeAliasDef> {
|
fn source(&self, db: &impl db::DefDatabase) -> Source<ast::TypeAliasDef> {
|
||||||
let node = self.ast_id.to_node(db);
|
let node = self.ast_id.to_node(db);
|
||||||
Source::new(self.ast_id.file_id(), node)
|
Source::new(self.ast_id.file_id(), node)
|
||||||
}
|
}
|
||||||
|
@ -578,7 +575,7 @@ impl HasSource for TypeAliasLoc {
|
||||||
impl HasSource for ConstLoc {
|
impl HasSource for ConstLoc {
|
||||||
type Value = ast::ConstDef;
|
type Value = ast::ConstDef;
|
||||||
|
|
||||||
fn source(&self, db: &impl db::DefDatabase2) -> Source<ast::ConstDef> {
|
fn source(&self, db: &impl db::DefDatabase) -> Source<ast::ConstDef> {
|
||||||
let node = self.ast_id.to_node(db);
|
let node = self.ast_id.to_node(db);
|
||||||
Source::new(self.ast_id.file_id(), node)
|
Source::new(self.ast_id.file_id(), node)
|
||||||
}
|
}
|
||||||
|
@ -589,6 +586,6 @@ pub trait HasChildSource {
|
||||||
type Value;
|
type Value;
|
||||||
fn child_source(
|
fn child_source(
|
||||||
&self,
|
&self,
|
||||||
db: &impl db::DefDatabase2,
|
db: &impl db::DefDatabase,
|
||||||
) -> Source<ArenaMap<Self::ChildId, Self::Value>>;
|
) -> Source<ArenaMap<Self::ChildId, Self::Value>>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
builtin_type::BuiltinType,
|
builtin_type::BuiltinType,
|
||||||
db::DefDatabase2,
|
db::DefDatabase,
|
||||||
nameres::{
|
nameres::{
|
||||||
diagnostics::DefDiagnostic, path_resolution::ResolveMode, per_ns::PerNs, raw::ImportId,
|
diagnostics::DefDiagnostic, path_resolution::ResolveMode, per_ns::PerNs, raw::ImportId,
|
||||||
},
|
},
|
||||||
|
@ -220,7 +220,7 @@ impl CrateDefMap {
|
||||||
pub(crate) fn crate_def_map_query(
|
pub(crate) fn crate_def_map_query(
|
||||||
// Note that this doesn't have `+ AstDatabase`!
|
// Note that this doesn't have `+ AstDatabase`!
|
||||||
// This gurantess that `CrateDefMap` is stable across reparses.
|
// This gurantess that `CrateDefMap` is stable across reparses.
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
krate: CrateId,
|
krate: CrateId,
|
||||||
) -> Arc<CrateDefMap> {
|
) -> Arc<CrateDefMap> {
|
||||||
let _p = profile("crate_def_map_query");
|
let _p = profile("crate_def_map_query");
|
||||||
|
@ -262,7 +262,7 @@ impl CrateDefMap {
|
||||||
|
|
||||||
pub fn add_diagnostics(
|
pub fn add_diagnostics(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
module: CrateModuleId,
|
module: CrateModuleId,
|
||||||
sink: &mut DiagnosticSink,
|
sink: &mut DiagnosticSink,
|
||||||
) {
|
) {
|
||||||
|
@ -271,7 +271,7 @@ impl CrateDefMap {
|
||||||
|
|
||||||
pub fn resolve_path(
|
pub fn resolve_path(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
original_module: CrateModuleId,
|
original_module: CrateModuleId,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
) -> (PerNs, Option<usize>) {
|
) -> (PerNs, Option<usize>) {
|
||||||
|
@ -295,7 +295,7 @@ impl ModuleData {
|
||||||
/// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
|
/// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
|
||||||
pub fn definition_source(
|
pub fn definition_source(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
) -> Source<Either<ast::SourceFile, ast::Module>> {
|
) -> Source<Either<ast::SourceFile, ast::Module>> {
|
||||||
if let Some(file_id) = self.definition {
|
if let Some(file_id) = self.definition {
|
||||||
let sf = db.parse(file_id).tree();
|
let sf = db.parse(file_id).tree();
|
||||||
|
@ -307,7 +307,7 @@ impl ModuleData {
|
||||||
|
|
||||||
/// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`.
|
/// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`.
|
||||||
/// `None` for the crate root.
|
/// `None` for the crate root.
|
||||||
pub fn declaration_source(&self, db: &impl DefDatabase2) -> Option<Source<ast::Module>> {
|
pub fn declaration_source(&self, db: &impl DefDatabase) -> Option<Source<ast::Module>> {
|
||||||
let decl = self.declaration?;
|
let decl = self.declaration?;
|
||||||
let value = decl.to_node(db);
|
let value = decl.to_node(db);
|
||||||
Some(Source { file_id: decl.file_id(), value })
|
Some(Source { file_id: decl.file_id(), value })
|
||||||
|
@ -319,7 +319,7 @@ mod diagnostics {
|
||||||
use ra_db::RelativePathBuf;
|
use ra_db::RelativePathBuf;
|
||||||
use ra_syntax::{ast, AstPtr};
|
use ra_syntax::{ast, AstPtr};
|
||||||
|
|
||||||
use crate::{db::DefDatabase2, diagnostics::UnresolvedModule, nameres::CrateModuleId, AstId};
|
use crate::{db::DefDatabase, diagnostics::UnresolvedModule, nameres::CrateModuleId, AstId};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub(super) enum DefDiagnostic {
|
pub(super) enum DefDiagnostic {
|
||||||
|
@ -333,7 +333,7 @@ mod diagnostics {
|
||||||
impl DefDiagnostic {
|
impl DefDiagnostic {
|
||||||
pub(super) fn add_to(
|
pub(super) fn add_to(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
target_module: CrateModuleId,
|
target_module: CrateModuleId,
|
||||||
sink: &mut DiagnosticSink,
|
sink: &mut DiagnosticSink,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ use test_utils::tested_by;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
attr::Attrs,
|
attr::Attrs,
|
||||||
db::DefDatabase2,
|
db::DefDatabase,
|
||||||
nameres::{
|
nameres::{
|
||||||
diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint,
|
diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint,
|
||||||
per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode,
|
per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode,
|
||||||
|
@ -24,7 +24,7 @@ use crate::{
|
||||||
StructOrUnionId, TraitId, TypeAliasLoc, UnionId,
|
StructOrUnionId, TraitId, TypeAliasLoc, UnionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(super) fn collect_defs(db: &impl DefDatabase2, mut def_map: CrateDefMap) -> CrateDefMap {
|
pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
|
||||||
let crate_graph = db.crate_graph();
|
let crate_graph = db.crate_graph();
|
||||||
|
|
||||||
// populate external prelude
|
// populate external prelude
|
||||||
|
@ -108,7 +108,7 @@ struct DefCollector<'a, DB> {
|
||||||
|
|
||||||
impl<DB> DefCollector<'_, DB>
|
impl<DB> DefCollector<'_, DB>
|
||||||
where
|
where
|
||||||
DB: DefDatabase2,
|
DB: DefDatabase,
|
||||||
{
|
{
|
||||||
fn collect(&mut self) {
|
fn collect(&mut self) {
|
||||||
let crate_graph = self.db.crate_graph();
|
let crate_graph = self.db.crate_graph();
|
||||||
|
@ -530,7 +530,7 @@ struct ModCollector<'a, D> {
|
||||||
|
|
||||||
impl<DB> ModCollector<'_, &'_ mut DefCollector<'_, DB>>
|
impl<DB> ModCollector<'_, &'_ mut DefCollector<'_, DB>>
|
||||||
where
|
where
|
||||||
DB: DefDatabase2,
|
DB: DefDatabase,
|
||||||
{
|
{
|
||||||
fn collect(&mut self, items: &[raw::RawItem]) {
|
fn collect(&mut self, items: &[raw::RawItem]) {
|
||||||
// Note: don't assert that inserted value is fresh: it's simply not true
|
// Note: don't assert that inserted value is fresh: it's simply not true
|
||||||
|
@ -798,12 +798,12 @@ mod tests {
|
||||||
use ra_db::{fixture::WithFixture, SourceDatabase};
|
use ra_db::{fixture::WithFixture, SourceDatabase};
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
|
||||||
use crate::{db::DefDatabase2, test_db::TestDB};
|
use crate::{db::DefDatabase, test_db::TestDB};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
fn do_collect_defs(
|
fn do_collect_defs(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
def_map: CrateDefMap,
|
def_map: CrateDefMap,
|
||||||
monitor: MacroStackMonitor,
|
monitor: MacroStackMonitor,
|
||||||
) -> CrateDefMap {
|
) -> CrateDefMap {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use hir_expand::name::Name;
|
||||||
use ra_db::{FileId, RelativePathBuf};
|
use ra_db::{FileId, RelativePathBuf};
|
||||||
use ra_syntax::SmolStr;
|
use ra_syntax::SmolStr;
|
||||||
|
|
||||||
use crate::{db::DefDatabase2, HirFileId};
|
use crate::{db::DefDatabase, HirFileId};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(super) struct ModDir {
|
pub(super) struct ModDir {
|
||||||
|
@ -40,7 +40,7 @@ impl ModDir {
|
||||||
|
|
||||||
pub(super) fn resolve_declaration(
|
pub(super) fn resolve_declaration(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
file_id: HirFileId,
|
file_id: HirFileId,
|
||||||
name: &Name,
|
name: &Name,
|
||||||
attr_path: Option<&SmolStr>,
|
attr_path: Option<&SmolStr>,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use ra_db::Edition;
|
||||||
use test_utils::tested_by;
|
use test_utils::tested_by;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase2,
|
db::DefDatabase,
|
||||||
nameres::{per_ns::PerNs, CrateDefMap},
|
nameres::{per_ns::PerNs, CrateDefMap},
|
||||||
path::{Path, PathKind},
|
path::{Path, PathKind},
|
||||||
AdtId, CrateModuleId, EnumVariantId, ModuleDefId, ModuleId,
|
AdtId, CrateModuleId, EnumVariantId, ModuleDefId, ModuleId,
|
||||||
|
@ -63,7 +63,7 @@ impl CrateDefMap {
|
||||||
// the result.
|
// the result.
|
||||||
pub(super) fn resolve_path_fp_with_macro(
|
pub(super) fn resolve_path_fp_with_macro(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
mode: ResolveMode,
|
mode: ResolveMode,
|
||||||
original_module: CrateModuleId,
|
original_module: CrateModuleId,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
|
@ -216,7 +216,7 @@ impl CrateDefMap {
|
||||||
|
|
||||||
fn resolve_name_in_module(
|
fn resolve_name_in_module(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
module: CrateModuleId,
|
module: CrateModuleId,
|
||||||
name: &Name,
|
name: &Name,
|
||||||
) -> PerNs {
|
) -> PerNs {
|
||||||
|
@ -243,7 +243,7 @@ impl CrateDefMap {
|
||||||
from_crate_root.or(from_extern_prelude)
|
from_crate_root.or(from_extern_prelude)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_in_prelude(&self, db: &impl DefDatabase2, name: &Name) -> PerNs {
|
fn resolve_in_prelude(&self, db: &impl DefDatabase, name: &Name) -> PerNs {
|
||||||
if let Some(prelude) = self.prelude {
|
if let Some(prelude) = self.prelude {
|
||||||
let keep;
|
let keep;
|
||||||
let def_map = if prelude.krate == self.krate {
|
let def_map = if prelude.krate == self.krate {
|
||||||
|
|
|
@ -18,7 +18,7 @@ use test_utils::tested_by;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
attr::{Attr, Attrs},
|
attr::{Attr, Attrs},
|
||||||
db::DefDatabase2,
|
db::DefDatabase,
|
||||||
path::Path,
|
path::Path,
|
||||||
FileAstId, HirFileId, ModuleSource, Source,
|
FileAstId, HirFileId, ModuleSource, Source,
|
||||||
};
|
};
|
||||||
|
@ -67,14 +67,14 @@ impl ImportSourceMap {
|
||||||
|
|
||||||
impl RawItems {
|
impl RawItems {
|
||||||
pub(crate) fn raw_items_query(
|
pub(crate) fn raw_items_query(
|
||||||
db: &(impl DefDatabase2 + AstDatabase),
|
db: &(impl DefDatabase + AstDatabase),
|
||||||
file_id: HirFileId,
|
file_id: HirFileId,
|
||||||
) -> Arc<RawItems> {
|
) -> Arc<RawItems> {
|
||||||
db.raw_items_with_source_map(file_id).0
|
db.raw_items_with_source_map(file_id).0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn raw_items_with_source_map_query(
|
pub(crate) fn raw_items_with_source_map_query(
|
||||||
db: &(impl DefDatabase2 + AstDatabase),
|
db: &(impl DefDatabase + AstDatabase),
|
||||||
file_id: HirFileId,
|
file_id: HirFileId,
|
||||||
) -> (Arc<RawItems>, Arc<ImportSourceMap>) {
|
) -> (Arc<RawItems>, Arc<ImportSourceMap>) {
|
||||||
let mut collector = RawItemsCollector {
|
let mut collector = RawItemsCollector {
|
||||||
|
|
|
@ -10,7 +10,7 @@ use insta::assert_snapshot;
|
||||||
use ra_db::{fixture::WithFixture, SourceDatabase};
|
use ra_db::{fixture::WithFixture, SourceDatabase};
|
||||||
use test_utils::covers;
|
use test_utils::covers;
|
||||||
|
|
||||||
use crate::{db::DefDatabase2, nameres::*, test_db::TestDB, CrateModuleId};
|
use crate::{db::DefDatabase, nameres::*, test_db::TestDB, CrateModuleId};
|
||||||
|
|
||||||
fn def_map(fixtute: &str) -> String {
|
fn def_map(fixtute: &str) -> String {
|
||||||
let dm = compute_crate_def_map(fixtute);
|
let dm = compute_crate_def_map(fixtute);
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rustc_hash::FxHashSet;
|
||||||
use crate::{
|
use crate::{
|
||||||
body::scope::{ExprScopes, ScopeId},
|
body::scope::{ExprScopes, ScopeId},
|
||||||
builtin_type::BuiltinType,
|
builtin_type::BuiltinType,
|
||||||
db::DefDatabase2,
|
db::DefDatabase,
|
||||||
expr::{ExprId, PatId},
|
expr::{ExprId, PatId},
|
||||||
generics::GenericParams,
|
generics::GenericParams,
|
||||||
nameres::{per_ns::PerNs, CrateDefMap},
|
nameres::{per_ns::PerNs, CrateDefMap},
|
||||||
|
@ -87,7 +87,7 @@ pub enum ValueNs {
|
||||||
|
|
||||||
impl Resolver {
|
impl Resolver {
|
||||||
/// Resolve known trait from std, like `std::futures::Future`
|
/// Resolve known trait from std, like `std::futures::Future`
|
||||||
pub fn resolve_known_trait(&self, db: &impl DefDatabase2, path: &Path) -> Option<TraitId> {
|
pub fn resolve_known_trait(&self, db: &impl DefDatabase, path: &Path) -> Option<TraitId> {
|
||||||
let res = self.resolve_module_path(db, path).take_types()?;
|
let res = self.resolve_module_path(db, path).take_types()?;
|
||||||
match res {
|
match res {
|
||||||
ModuleDefId::TraitId(it) => Some(it),
|
ModuleDefId::TraitId(it) => Some(it),
|
||||||
|
@ -96,7 +96,7 @@ impl Resolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resolve known struct from std, like `std::boxed::Box`
|
/// Resolve known struct from std, like `std::boxed::Box`
|
||||||
pub fn resolve_known_struct(&self, db: &impl DefDatabase2, path: &Path) -> Option<StructId> {
|
pub fn resolve_known_struct(&self, db: &impl DefDatabase, path: &Path) -> Option<StructId> {
|
||||||
let res = self.resolve_module_path(db, path).take_types()?;
|
let res = self.resolve_module_path(db, path).take_types()?;
|
||||||
match res {
|
match res {
|
||||||
ModuleDefId::AdtId(AdtId::StructId(it)) => Some(it),
|
ModuleDefId::AdtId(AdtId::StructId(it)) => Some(it),
|
||||||
|
@ -105,7 +105,7 @@ impl Resolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resolve known enum from std, like `std::result::Result`
|
/// Resolve known enum from std, like `std::result::Result`
|
||||||
pub fn resolve_known_enum(&self, db: &impl DefDatabase2, path: &Path) -> Option<EnumId> {
|
pub fn resolve_known_enum(&self, db: &impl DefDatabase, path: &Path) -> Option<EnumId> {
|
||||||
let res = self.resolve_module_path(db, path).take_types()?;
|
let res = self.resolve_module_path(db, path).take_types()?;
|
||||||
match res {
|
match res {
|
||||||
ModuleDefId::AdtId(AdtId::EnumId(it)) => Some(it),
|
ModuleDefId::AdtId(AdtId::EnumId(it)) => Some(it),
|
||||||
|
@ -114,7 +114,7 @@ impl Resolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// pub only for source-binder
|
/// pub only for source-binder
|
||||||
pub fn resolve_module_path(&self, db: &impl DefDatabase2, path: &Path) -> PerNs {
|
pub fn resolve_module_path(&self, db: &impl DefDatabase, path: &Path) -> PerNs {
|
||||||
let (item_map, module) = match self.module() {
|
let (item_map, module) = match self.module() {
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
None => return PerNs::none(),
|
None => return PerNs::none(),
|
||||||
|
@ -128,7 +128,7 @@ impl Resolver {
|
||||||
|
|
||||||
pub fn resolve_path_in_type_ns(
|
pub fn resolve_path_in_type_ns(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
) -> Option<(TypeNs, Option<usize>)> {
|
) -> Option<(TypeNs, Option<usize>)> {
|
||||||
if path.is_type_relative() {
|
if path.is_type_relative() {
|
||||||
|
@ -184,7 +184,7 @@ impl Resolver {
|
||||||
|
|
||||||
pub fn resolve_path_in_type_ns_fully(
|
pub fn resolve_path_in_type_ns_fully(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
) -> Option<TypeNs> {
|
) -> Option<TypeNs> {
|
||||||
let (res, unresolved) = self.resolve_path_in_type_ns(db, path)?;
|
let (res, unresolved) = self.resolve_path_in_type_ns(db, path)?;
|
||||||
|
@ -196,7 +196,7 @@ impl Resolver {
|
||||||
|
|
||||||
pub fn resolve_path_in_value_ns<'p>(
|
pub fn resolve_path_in_value_ns<'p>(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
path: &'p Path,
|
path: &'p Path,
|
||||||
) -> Option<ResolveValueResult> {
|
) -> Option<ResolveValueResult> {
|
||||||
if path.is_type_relative() {
|
if path.is_type_relative() {
|
||||||
|
@ -296,7 +296,7 @@ impl Resolver {
|
||||||
|
|
||||||
pub fn resolve_path_in_value_ns_fully(
|
pub fn resolve_path_in_value_ns_fully(
|
||||||
&self,
|
&self,
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
) -> Option<ValueNs> {
|
) -> Option<ValueNs> {
|
||||||
match self.resolve_path_in_value_ns(db, path)? {
|
match self.resolve_path_in_value_ns(db, path)? {
|
||||||
|
@ -305,18 +305,18 @@ impl Resolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option<MacroDefId> {
|
pub fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
|
||||||
let (item_map, module) = self.module()?;
|
let (item_map, module) = self.module()?;
|
||||||
item_map.resolve_path(db, module, path).0.get_macros()
|
item_map.resolve_path(db, module, path).0.get_macros()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_all_names(&self, db: &impl DefDatabase2, f: &mut dyn FnMut(Name, ScopeDef)) {
|
pub fn process_all_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) {
|
||||||
for scope in self.scopes.iter().rev() {
|
for scope in self.scopes.iter().rev() {
|
||||||
scope.process_names(db, f);
|
scope.process_names(db, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn traits_in_scope(&self, db: &impl DefDatabase2) -> FxHashSet<TraitId> {
|
pub fn traits_in_scope(&self, db: &impl DefDatabase) -> FxHashSet<TraitId> {
|
||||||
let mut traits = FxHashSet::default();
|
let mut traits = FxHashSet::default();
|
||||||
for scope in &self.scopes {
|
for scope in &self.scopes {
|
||||||
if let Scope::ModuleScope(m) = scope {
|
if let Scope::ModuleScope(m) = scope {
|
||||||
|
@ -378,7 +378,7 @@ pub enum ScopeDef {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Scope {
|
impl Scope {
|
||||||
fn process_names(&self, db: &impl DefDatabase2, f: &mut dyn FnMut(Name, ScopeDef)) {
|
fn process_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) {
|
||||||
match self {
|
match self {
|
||||||
Scope::ModuleScope(m) => {
|
Scope::ModuleScope(m) => {
|
||||||
// FIXME: should we provide `self` here?
|
// FIXME: should we provide `self` here?
|
||||||
|
@ -425,17 +425,13 @@ impl Scope {
|
||||||
}
|
}
|
||||||
|
|
||||||
// needs arbitrary_self_types to be a method... or maybe move to the def?
|
// needs arbitrary_self_types to be a method... or maybe move to the def?
|
||||||
pub fn resolver_for_expr(
|
pub fn resolver_for_expr(db: &impl DefDatabase, owner: DefWithBodyId, expr_id: ExprId) -> Resolver {
|
||||||
db: &impl DefDatabase2,
|
|
||||||
owner: DefWithBodyId,
|
|
||||||
expr_id: ExprId,
|
|
||||||
) -> Resolver {
|
|
||||||
let scopes = db.expr_scopes(owner);
|
let scopes = db.expr_scopes(owner);
|
||||||
resolver_for_scope(db, owner, scopes.scope_for(expr_id))
|
resolver_for_scope(db, owner, scopes.scope_for(expr_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolver_for_scope(
|
pub fn resolver_for_scope(
|
||||||
db: &impl DefDatabase2,
|
db: &impl DefDatabase,
|
||||||
owner: DefWithBodyId,
|
owner: DefWithBodyId,
|
||||||
scope_id: Option<ScopeId>,
|
scope_id: Option<ScopeId>,
|
||||||
) -> Resolver {
|
) -> Resolver {
|
||||||
|
@ -454,7 +450,7 @@ impl Resolver {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_generic_params_scope(self, db: &impl DefDatabase2, def: GenericDefId) -> Resolver {
|
fn push_generic_params_scope(self, db: &impl DefDatabase, def: GenericDefId) -> Resolver {
|
||||||
let params = db.generic_params(def);
|
let params = db.generic_params(def);
|
||||||
if params.params.is_empty() {
|
if params.params.is_empty() {
|
||||||
self
|
self
|
||||||
|
@ -487,24 +483,24 @@ impl Resolver {
|
||||||
|
|
||||||
pub trait HasResolver {
|
pub trait HasResolver {
|
||||||
/// Builds a resolver for type references inside this def.
|
/// Builds a resolver for type references inside this def.
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver;
|
fn resolver(self, db: &impl DefDatabase) -> Resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for ModuleId {
|
impl HasResolver for ModuleId {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
let def_map = db.crate_def_map(self.krate);
|
let def_map = db.crate_def_map(self.krate);
|
||||||
Resolver::default().push_module_scope(def_map, self.module_id)
|
Resolver::default().push_module_scope(def_map, self.module_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for TraitId {
|
impl HasResolver for TraitId {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
self.module(db).resolver(db).push_generic_params_scope(db, self.into())
|
self.module(db).resolver(db).push_generic_params_scope(db, self.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Into<AdtId>> HasResolver for T {
|
impl<T: Into<AdtId>> HasResolver for T {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
let def = self.into();
|
let def = self.into();
|
||||||
let module = match def {
|
let module = match def {
|
||||||
AdtId::StructId(it) => it.0.module(db),
|
AdtId::StructId(it) => it.0.module(db),
|
||||||
|
@ -520,13 +516,13 @@ impl<T: Into<AdtId>> HasResolver for T {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for FunctionId {
|
impl HasResolver for FunctionId {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
self.lookup(db).container.resolver(db).push_generic_params_scope(db, self.into())
|
self.lookup(db).container.resolver(db).push_generic_params_scope(db, self.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for DefWithBodyId {
|
impl HasResolver for DefWithBodyId {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
match self {
|
match self {
|
||||||
DefWithBodyId::ConstId(c) => c.resolver(db),
|
DefWithBodyId::ConstId(c) => c.resolver(db),
|
||||||
DefWithBodyId::FunctionId(f) => f.resolver(db),
|
DefWithBodyId::FunctionId(f) => f.resolver(db),
|
||||||
|
@ -536,25 +532,25 @@ impl HasResolver for DefWithBodyId {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for ConstId {
|
impl HasResolver for ConstId {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
self.lookup(db).container.resolver(db)
|
self.lookup(db).container.resolver(db)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for StaticId {
|
impl HasResolver for StaticId {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
self.module(db).resolver(db)
|
self.module(db).resolver(db)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for TypeAliasId {
|
impl HasResolver for TypeAliasId {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
self.lookup(db).container.resolver(db).push_generic_params_scope(db, self.into())
|
self.lookup(db).container.resolver(db).push_generic_params_scope(db, self.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for ContainerId {
|
impl HasResolver for ContainerId {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
match self {
|
match self {
|
||||||
ContainerId::TraitId(it) => it.resolver(db),
|
ContainerId::TraitId(it) => it.resolver(db),
|
||||||
ContainerId::ImplId(it) => it.resolver(db),
|
ContainerId::ImplId(it) => it.resolver(db),
|
||||||
|
@ -564,7 +560,7 @@ impl HasResolver for ContainerId {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for GenericDefId {
|
impl HasResolver for GenericDefId {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
match self {
|
match self {
|
||||||
GenericDefId::FunctionId(inner) => inner.resolver(db),
|
GenericDefId::FunctionId(inner) => inner.resolver(db),
|
||||||
GenericDefId::AdtId(adt) => adt.resolver(db),
|
GenericDefId::AdtId(adt) => adt.resolver(db),
|
||||||
|
@ -578,7 +574,7 @@ impl HasResolver for GenericDefId {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasResolver for ImplId {
|
impl HasResolver for ImplId {
|
||||||
fn resolver(self, db: &impl DefDatabase2) -> Resolver {
|
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||||
self.module(db)
|
self.module(db)
|
||||||
.resolver(db)
|
.resolver(db)
|
||||||
.push_generic_params_scope(db, self.into())
|
.push_generic_params_scope(db, self.into())
|
||||||
|
|
|
@ -12,7 +12,7 @@ use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath
|
||||||
ra_db::SourceDatabaseStorage,
|
ra_db::SourceDatabaseStorage,
|
||||||
hir_expand::db::AstDatabaseStorage,
|
hir_expand::db::AstDatabaseStorage,
|
||||||
crate::db::InternDatabaseStorage,
|
crate::db::InternDatabaseStorage,
|
||||||
crate::db::DefDatabase2Storage
|
crate::db::DefDatabaseStorage
|
||||||
)]
|
)]
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct TestDB {
|
pub struct TestDB {
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::{
|
||||||
symbol_index::SymbolsDatabaseStorage,
|
symbol_index::SymbolsDatabaseStorage,
|
||||||
hir::db::InternDatabaseStorage,
|
hir::db::InternDatabaseStorage,
|
||||||
hir::db::AstDatabaseStorage,
|
hir::db::AstDatabaseStorage,
|
||||||
hir::db::DefDatabase2Storage,
|
hir::db::DefDatabaseStorage,
|
||||||
hir::db::HirDatabaseStorage
|
hir::db::HirDatabaseStorage
|
||||||
)]
|
)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue