diff options
author | Aleksey Kladov <[email protected]> | 2019-11-23 11:44:43 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-23 11:49:45 +0000 |
commit | fc1e543f7abb69b8cab308410fa0a127950ee1c5 (patch) | |
tree | 5e30f4e18a0ea83215fd48776f372546dece9431 /crates | |
parent | 958862093e83083b188427246323047a2c9e7bab (diff) |
Get rid of DefDatabase2
Diffstat (limited to 'crates')
23 files changed, 123 insertions, 135 deletions
diff --git a/crates/ra_assists/src/test_db.rs b/crates/ra_assists/src/test_db.rs index 715270344..5f96c974b 100644 --- a/crates/ra_assists/src/test_db.rs +++ b/crates/ra_assists/src/test_db.rs | |||
@@ -9,7 +9,7 @@ use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath | |||
9 | ra_db::SourceDatabaseStorage, | 9 | ra_db::SourceDatabaseStorage, |
10 | hir::db::InternDatabaseStorage, | 10 | hir::db::InternDatabaseStorage, |
11 | hir::db::AstDatabaseStorage, | 11 | hir::db::AstDatabaseStorage, |
12 | hir::db::DefDatabase2Storage, | 12 | hir::db::DefDatabaseStorage, |
13 | hir::db::HirDatabaseStorage | 13 | hir::db::HirDatabaseStorage |
14 | )] | 14 | )] |
15 | #[derive(Debug, Default)] | 15 | #[derive(Debug, Default)] |
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 2dca0f637..399101b83 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | 17 | ||
18 | pub use hir_def::db::{ | 18 | pub use hir_def::db::{ |
19 | BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery, | 19 | BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery, |
20 | DefDatabase2, DefDatabase2Storage, DocumentationQuery, EnumDataQuery, ExprScopesQuery, | 20 | DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, ExprScopesQuery, |
21 | FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, InternDatabaseStorage, | 21 | FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, InternDatabaseStorage, |
22 | LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, RawItemsWithSourceMapQuery, | 22 | LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, RawItemsWithSourceMapQuery, |
23 | StaticDataQuery, StructDataQuery, TraitDataQuery, TypeAliasDataQuery, | 23 | StaticDataQuery, StructDataQuery, TraitDataQuery, TypeAliasDataQuery, |
@@ -27,8 +27,6 @@ pub use hir_expand::db::{ | |||
27 | ParseMacroQuery, | 27 | ParseMacroQuery, |
28 | }; | 28 | }; |
29 | 29 | ||
30 | pub use DefDatabase2 as DefDatabase; | ||
31 | |||
32 | #[salsa::query_group(HirDatabaseStorage)] | 30 | #[salsa::query_group(HirDatabaseStorage)] |
33 | #[salsa::requires(salsa::Database)] | 31 | #[salsa::requires(salsa::Database)] |
34 | pub trait HirDatabase: DefDatabase + AstDatabase { | 32 | pub trait HirDatabase: DefDatabase + AstDatabase { |
diff --git a/crates/ra_hir/src/test_db.rs b/crates/ra_hir/src/test_db.rs index c369a80d4..03c7ac155 100644 --- a/crates/ra_hir/src/test_db.rs +++ b/crates/ra_hir/src/test_db.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use std::{panic, sync::Arc}; | 3 | use std::{panic, sync::Arc}; |
4 | 4 | ||
5 | use hir_def::{db::DefDatabase2, ModuleId}; | 5 | use hir_def::{db::DefDatabase, ModuleId}; |
6 | use hir_expand::diagnostics::DiagnosticSink; | 6 | use hir_expand::diagnostics::DiagnosticSink; |
7 | use parking_lot::Mutex; | 7 | use parking_lot::Mutex; |
8 | use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase}; | 8 | use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase}; |
@@ -14,7 +14,7 @@ use crate::{db, debug::HirDebugHelper}; | |||
14 | ra_db::SourceDatabaseStorage, | 14 | ra_db::SourceDatabaseStorage, |
15 | db::InternDatabaseStorage, | 15 | db::InternDatabaseStorage, |
16 | db::AstDatabaseStorage, | 16 | db::AstDatabaseStorage, |
17 | db::DefDatabase2Storage, | 17 | db::DefDatabaseStorage, |
18 | db::HirDatabaseStorage | 18 | db::HirDatabaseStorage |
19 | )] | 19 | )] |
20 | #[derive(Debug, Default)] | 20 | #[derive(Debug, Default)] |
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index ae99afe39..20e9a1eb5 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs | |||
@@ -11,7 +11,7 @@ use ra_arena::{map::ArenaMap, Arena}; | |||
11 | use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; | 11 | use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; |
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | db::DefDatabase2, trace::Trace, type_ref::TypeRef, AstItemDef, EnumId, HasChildSource, | 14 | db::DefDatabase, trace::Trace, type_ref::TypeRef, AstItemDef, EnumId, HasChildSource, |
15 | LocalEnumVariantId, LocalStructFieldId, StructOrUnionId, VariantId, | 15 | LocalEnumVariantId, LocalStructFieldId, StructOrUnionId, VariantId, |
16 | }; | 16 | }; |
17 | 17 | ||
@@ -49,10 +49,7 @@ pub struct StructFieldData { | |||
49 | } | 49 | } |
50 | 50 | ||
51 | impl StructData { | 51 | impl StructData { |
52 | pub(crate) fn struct_data_query( | 52 | pub(crate) fn struct_data_query(db: &impl DefDatabase, id: StructOrUnionId) -> Arc<StructData> { |
53 | db: &impl DefDatabase2, | ||
54 | id: StructOrUnionId, | ||
55 | ) -> Arc<StructData> { | ||
56 | let src = id.source(db); | 53 | let src = id.source(db); |
57 | let name = src.value.name().map(|n| n.as_name()); | 54 | let name = src.value.name().map(|n| n.as_name()); |
58 | let variant_data = VariantData::new(src.value.kind()); | 55 | let variant_data = VariantData::new(src.value.kind()); |
@@ -62,7 +59,7 @@ impl StructData { | |||
62 | } | 59 | } |
63 | 60 | ||
64 | impl EnumData { | 61 | impl EnumData { |
65 | pub(crate) fn enum_data_query(db: &impl DefDatabase2, e: EnumId) -> Arc<EnumData> { | 62 | pub(crate) fn enum_data_query(db: &impl DefDatabase, e: EnumId) -> Arc<EnumData> { |
66 | let src = e.source(db); | 63 | let src = e.source(db); |
67 | let name = src.value.name().map(|n| n.as_name()); | 64 | let name = src.value.name().map(|n| n.as_name()); |
68 | let mut trace = Trace::new_for_arena(); | 65 | let mut trace = Trace::new_for_arena(); |
@@ -79,7 +76,7 @@ impl EnumData { | |||
79 | impl HasChildSource for EnumId { | 76 | impl HasChildSource for EnumId { |
80 | type ChildId = LocalEnumVariantId; | 77 | type ChildId = LocalEnumVariantId; |
81 | type Value = ast::EnumVariant; | 78 | type Value = ast::EnumVariant; |
82 | fn child_source(&self, db: &impl DefDatabase2) -> Source<ArenaMap<Self::ChildId, Self::Value>> { | 79 | fn child_source(&self, db: &impl DefDatabase) -> Source<ArenaMap<Self::ChildId, Self::Value>> { |
83 | let src = self.source(db); | 80 | let src = self.source(db); |
84 | let mut trace = Trace::new_for_map(); | 81 | let mut trace = Trace::new_for_map(); |
85 | lower_enum(&mut trace, &src.value); | 82 | lower_enum(&mut trace, &src.value); |
@@ -124,7 +121,7 @@ impl HasChildSource for VariantId { | |||
124 | type ChildId = LocalStructFieldId; | 121 | type ChildId = LocalStructFieldId; |
125 | type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>; | 122 | type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>; |
126 | 123 | ||
127 | fn child_source(&self, db: &impl DefDatabase2) -> Source<ArenaMap<Self::ChildId, Self::Value>> { | 124 | fn child_source(&self, db: &impl DefDatabase) -> Source<ArenaMap<Self::ChildId, Self::Value>> { |
128 | let src = match self { | 125 | let src = match self { |
129 | VariantId::EnumVariantId(it) => { | 126 | VariantId::EnumVariantId(it) => { |
130 | // I don't really like the fact that we call into parent source | 127 | // I don't really like the fact that we call into parent source |
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index eee5e44bf..48ce8cd93 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs | |||
@@ -12,7 +12,7 @@ use ra_syntax::{ | |||
12 | use tt::Subtree; | 12 | use tt::Subtree; |
13 | 13 | ||
14 | use crate::{ | 14 | use crate::{ |
15 | db::DefDatabase2, path::Path, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup, | 15 | db::DefDatabase, path::Path, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | #[derive(Default, Debug, Clone, PartialEq, Eq)] | 18 | #[derive(Default, Debug, Clone, PartialEq, Eq)] |
@@ -32,7 +32,7 @@ impl ops::Deref for Attrs { | |||
32 | } | 32 | } |
33 | 33 | ||
34 | impl Attrs { | 34 | impl Attrs { |
35 | pub(crate) fn attrs_query(db: &impl DefDatabase2, def: AttrDefId) -> Attrs { | 35 | pub(crate) fn attrs_query(db: &impl DefDatabase, def: AttrDefId) -> Attrs { |
36 | match def { | 36 | match def { |
37 | AttrDefId::ModuleId(module) => { | 37 | AttrDefId::ModuleId(module) => { |
38 | let def_map = db.crate_def_map(module.krate); | 38 | let def_map = db.crate_def_map(module.krate); |
@@ -162,7 +162,7 @@ impl Attr { | |||
162 | fn attrs_from_ast<D, N>(src: AstId<N>, db: &D) -> Attrs | 162 | fn attrs_from_ast<D, N>(src: AstId<N>, db: &D) -> Attrs |
163 | where | 163 | where |
164 | N: ast::AttrsOwner, | 164 | N: ast::AttrsOwner, |
165 | D: DefDatabase2, | 165 | D: DefDatabase, |
166 | { | 166 | { |
167 | let hygiene = Hygiene::new(db, src.file_id()); | 167 | let hygiene = Hygiene::new(db, src.file_id()); |
168 | Attr::from_attrs_owner(&src.to_node(db), &hygiene) | 168 | Attr::from_attrs_owner(&src.to_node(db), &hygiene) |
@@ -172,7 +172,7 @@ fn attrs_from_loc<T, D>(node: T, db: &D) -> Attrs | |||
172 | where | 172 | where |
173 | T: HasSource, | 173 | T: HasSource, |
174 | T::Value: ast::AttrsOwner, | 174 | T::Value: ast::AttrsOwner, |
175 | D: DefDatabase2, | 175 | D: DefDatabase, |
176 | { | 176 | { |
177 | let src = node.source(db); | 177 | let src = node.source(db); |
178 | let hygiene = Hygiene::new(db, src.file_id); | 178 | let hygiene = Hygiene::new(db, src.file_id); |
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index dfb79a30a..225638b42 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs | |||
@@ -13,7 +13,7 @@ use ra_syntax::{ast, AstNode, AstPtr}; | |||
13 | use rustc_hash::FxHashMap; | 13 | use rustc_hash::FxHashMap; |
14 | 14 | ||
15 | use crate::{ | 15 | use crate::{ |
16 | db::DefDatabase2, | 16 | db::DefDatabase, |
17 | expr::{Expr, ExprId, Pat, PatId}, | 17 | expr::{Expr, ExprId, Pat, PatId}, |
18 | nameres::CrateDefMap, | 18 | nameres::CrateDefMap, |
19 | path::Path, | 19 | path::Path, |
@@ -28,7 +28,7 @@ pub struct Expander { | |||
28 | } | 28 | } |
29 | 29 | ||
30 | impl Expander { | 30 | impl Expander { |
31 | pub fn new(db: &impl DefDatabase2, current_file_id: HirFileId, module: ModuleId) -> Expander { | 31 | pub fn new(db: &impl DefDatabase, current_file_id: HirFileId, module: ModuleId) -> Expander { |
32 | let crate_def_map = db.crate_def_map(module.krate); | 32 | let crate_def_map = db.crate_def_map(module.krate); |
33 | let hygiene = Hygiene::new(db, current_file_id); | 33 | let hygiene = Hygiene::new(db, current_file_id); |
34 | Expander { crate_def_map, current_file_id, hygiene, module } | 34 | Expander { crate_def_map, current_file_id, hygiene, module } |
@@ -36,7 +36,7 @@ impl Expander { | |||
36 | 36 | ||
37 | fn enter_expand( | 37 | fn enter_expand( |
38 | &mut self, | 38 | &mut self, |
39 | db: &impl DefDatabase2, | 39 | db: &impl DefDatabase, |
40 | macro_call: ast::MacroCall, | 40 | macro_call: ast::MacroCall, |
41 | ) -> Option<(Mark, ast::Expr)> { | 41 | ) -> Option<(Mark, ast::Expr)> { |
42 | let ast_id = AstId::new( | 42 | let ast_id = AstId::new( |
@@ -67,7 +67,7 @@ impl Expander { | |||
67 | None | 67 | None |
68 | } | 68 | } |
69 | 69 | ||
70 | fn exit(&mut self, db: &impl DefDatabase2, mark: Mark) { | 70 | fn exit(&mut self, db: &impl DefDatabase, mark: Mark) { |
71 | self.hygiene = Hygiene::new(db, mark.file_id); | 71 | self.hygiene = Hygiene::new(db, mark.file_id); |
72 | self.current_file_id = mark.file_id; | 72 | self.current_file_id = mark.file_id; |
73 | std::mem::forget(mark); | 73 | std::mem::forget(mark); |
@@ -81,7 +81,7 @@ impl Expander { | |||
81 | Path::from_src(path, &self.hygiene) | 81 | Path::from_src(path, &self.hygiene) |
82 | } | 82 | } |
83 | 83 | ||
84 | fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option<MacroDefId> { | 84 | fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> { |
85 | self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros() | 85 | self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros() |
86 | } | 86 | } |
87 | } | 87 | } |
@@ -142,7 +142,7 @@ pub struct BodySourceMap { | |||
142 | 142 | ||
143 | impl Body { | 143 | impl Body { |
144 | pub(crate) fn body_with_source_map_query( | 144 | pub(crate) fn body_with_source_map_query( |
145 | db: &impl DefDatabase2, | 145 | db: &impl DefDatabase, |
146 | def: DefWithBodyId, | 146 | def: DefWithBodyId, |
147 | ) -> (Arc<Body>, Arc<BodySourceMap>) { | 147 | ) -> (Arc<Body>, Arc<BodySourceMap>) { |
148 | let mut params = None; | 148 | let mut params = None; |
@@ -169,12 +169,12 @@ impl Body { | |||
169 | (Arc::new(body), Arc::new(source_map)) | 169 | (Arc::new(body), Arc::new(source_map)) |
170 | } | 170 | } |
171 | 171 | ||
172 | pub(crate) fn body_query(db: &impl DefDatabase2, def: DefWithBodyId) -> Arc<Body> { | 172 | pub(crate) fn body_query(db: &impl DefDatabase, def: DefWithBodyId) -> Arc<Body> { |
173 | db.body_with_source_map(def).0 | 173 | db.body_with_source_map(def).0 |
174 | } | 174 | } |
175 | 175 | ||
176 | fn new( | 176 | fn new( |
177 | db: &impl DefDatabase2, | 177 | db: &impl DefDatabase, |
178 | expander: Expander, | 178 | expander: Expander, |
179 | params: Option<ast::ParamList>, | 179 | params: Option<ast::ParamList>, |
180 | body: Option<ast::Expr>, | 180 | body: Option<ast::Expr>, |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index d8e911aa5..f4640dfa4 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -17,7 +17,7 @@ use test_utils::tested_by; | |||
17 | use crate::{ | 17 | use crate::{ |
18 | body::{Body, BodySourceMap, Expander, PatPtr}, | 18 | body::{Body, BodySourceMap, Expander, PatPtr}, |
19 | builtin_type::{BuiltinFloat, BuiltinInt}, | 19 | builtin_type::{BuiltinFloat, BuiltinInt}, |
20 | db::DefDatabase2, | 20 | db::DefDatabase, |
21 | expr::{ | 21 | expr::{ |
22 | ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp, | 22 | ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp, |
23 | MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement, | 23 | MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement, |
@@ -28,7 +28,7 @@ use crate::{ | |||
28 | }; | 28 | }; |
29 | 29 | ||
30 | pub(super) fn lower( | 30 | pub(super) fn lower( |
31 | db: &impl DefDatabase2, | 31 | db: &impl DefDatabase, |
32 | expander: Expander, | 32 | expander: Expander, |
33 | params: Option<ast::ParamList>, | 33 | params: Option<ast::ParamList>, |
34 | body: Option<ast::Expr>, | 34 | body: Option<ast::Expr>, |
@@ -57,7 +57,7 @@ struct ExprCollector<DB> { | |||
57 | 57 | ||
58 | impl<'a, DB> ExprCollector<&'a DB> | 58 | impl<'a, DB> ExprCollector<&'a DB> |
59 | where | 59 | where |
60 | DB: DefDatabase2, | 60 | DB: DefDatabase, |
61 | { | 61 | { |
62 | fn collect( | 62 | fn collect( |
63 | mut self, | 63 | mut self, |
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 58740b679..20d707bc4 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs | |||
@@ -7,7 +7,7 @@ use rustc_hash::FxHashMap; | |||
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | body::Body, | 9 | body::Body, |
10 | db::DefDatabase2, | 10 | db::DefDatabase, |
11 | expr::{Expr, ExprId, Pat, PatId, Statement}, | 11 | expr::{Expr, ExprId, Pat, PatId, Statement}, |
12 | DefWithBodyId, | 12 | DefWithBodyId, |
13 | }; | 13 | }; |
@@ -45,7 +45,7 @@ pub struct ScopeData { | |||
45 | } | 45 | } |
46 | 46 | ||
47 | impl ExprScopes { | 47 | impl ExprScopes { |
48 | pub(crate) fn expr_scopes_query(db: &impl DefDatabase2, def: DefWithBodyId) -> Arc<ExprScopes> { | 48 | pub(crate) fn expr_scopes_query(db: &impl DefDatabase, def: DefWithBodyId) -> Arc<ExprScopes> { |
49 | let body = db.body(def); | 49 | let body = db.body(def); |
50 | Arc::new(ExprScopes::new(&*body)) | 50 | Arc::new(ExprScopes::new(&*body)) |
51 | } | 51 | } |
@@ -176,7 +176,7 @@ mod tests { | |||
176 | use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; | 176 | use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; |
177 | use test_utils::{assert_eq_text, covers, extract_offset}; | 177 | use test_utils::{assert_eq_text, covers, extract_offset}; |
178 | 178 | ||
179 | use crate::{db::DefDatabase2, test_db::TestDB, FunctionId, ModuleDefId}; | 179 | use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId}; |
180 | 180 | ||
181 | fn find_function(db: &TestDB, file_id: FileId) -> FunctionId { | 181 | fn find_function(db: &TestDB, file_id: FileId) -> FunctionId { |
182 | let krate = db.test_crate(); | 182 | let krate = db.test_crate(); |
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index 91bac7415..f0b3e198a 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs | |||
@@ -9,7 +9,7 @@ use hir_expand::{ | |||
9 | use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; | 9 | use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | db::DefDatabase2, | 12 | db::DefDatabase, |
13 | type_ref::{Mutability, TypeRef}, | 13 | type_ref::{Mutability, TypeRef}, |
14 | AssocItemId, AstItemDef, ConstId, ConstLoc, ContainerId, FunctionId, FunctionLoc, HasSource, | 14 | AssocItemId, AstItemDef, ConstId, ConstLoc, ContainerId, FunctionId, FunctionLoc, HasSource, |
15 | ImplId, Intern, Lookup, StaticId, TraitId, TypeAliasId, TypeAliasLoc, | 15 | ImplId, Intern, Lookup, StaticId, TraitId, TypeAliasId, TypeAliasLoc, |
@@ -26,7 +26,7 @@ pub struct FunctionData { | |||
26 | } | 26 | } |
27 | 27 | ||
28 | impl FunctionData { | 28 | impl FunctionData { |
29 | pub(crate) fn fn_data_query(db: &impl DefDatabase2, func: FunctionId) -> Arc<FunctionData> { | 29 | pub(crate) fn fn_data_query(db: &impl DefDatabase, func: FunctionId) -> Arc<FunctionData> { |
30 | let src = func.lookup(db).source(db); | 30 | let src = func.lookup(db).source(db); |
31 | let name = src.value.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); | 31 | let name = src.value.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); |
32 | let mut params = Vec::new(); | 32 | let mut params = Vec::new(); |
@@ -74,7 +74,7 @@ pub struct TypeAliasData { | |||
74 | 74 | ||
75 | impl TypeAliasData { | 75 | impl TypeAliasData { |
76 | pub(crate) fn type_alias_data_query( | 76 | pub(crate) fn type_alias_data_query( |
77 | db: &impl DefDatabase2, | 77 | db: &impl DefDatabase, |
78 | typ: TypeAliasId, | 78 | typ: TypeAliasId, |
79 | ) -> Arc<TypeAliasData> { | 79 | ) -> Arc<TypeAliasData> { |
80 | let node = typ.lookup(db).source(db).value; | 80 | let node = typ.lookup(db).source(db).value; |
@@ -92,7 +92,7 @@ pub struct TraitData { | |||
92 | } | 92 | } |
93 | 93 | ||
94 | impl TraitData { | 94 | impl TraitData { |
95 | pub(crate) fn trait_data_query(db: &impl DefDatabase2, tr: TraitId) -> Arc<TraitData> { | 95 | pub(crate) fn trait_data_query(db: &impl DefDatabase, tr: TraitId) -> Arc<TraitData> { |
96 | let src = tr.source(db); | 96 | let src = tr.source(db); |
97 | let name = src.value.name().map(|n| n.as_name()); | 97 | let name = src.value.name().map(|n| n.as_name()); |
98 | let auto = src.value.is_auto(); | 98 | let auto = src.value.is_auto(); |
@@ -144,7 +144,7 @@ pub struct ImplData { | |||
144 | } | 144 | } |
145 | 145 | ||
146 | impl ImplData { | 146 | impl ImplData { |
147 | pub(crate) fn impl_data_query(db: &impl DefDatabase2, id: ImplId) -> Arc<ImplData> { | 147 | pub(crate) fn impl_data_query(db: &impl DefDatabase, id: ImplId) -> Arc<ImplData> { |
148 | let src = id.source(db); | 148 | let src = id.source(db); |
149 | let items = db.ast_id_map(src.file_id); | 149 | let items = db.ast_id_map(src.file_id); |
150 | 150 | ||
@@ -198,12 +198,12 @@ pub struct ConstData { | |||
198 | } | 198 | } |
199 | 199 | ||
200 | impl ConstData { | 200 | impl ConstData { |
201 | pub(crate) fn const_data_query(db: &impl DefDatabase2, konst: ConstId) -> Arc<ConstData> { | 201 | pub(crate) fn const_data_query(db: &impl DefDatabase, konst: ConstId) -> Arc<ConstData> { |
202 | let node = konst.lookup(db).source(db).value; | 202 | let node = konst.lookup(db).source(db).value; |
203 | const_data_for(&node) | 203 | const_data_for(&node) |
204 | } | 204 | } |
205 | 205 | ||
206 | pub(crate) fn static_data_query(db: &impl DefDatabase2, konst: StaticId) -> Arc<ConstData> { | 206 | pub(crate) fn static_data_query(db: &impl DefDatabase, konst: StaticId) -> Arc<ConstData> { |
207 | let node = konst.source(db).value; | 207 | let node = konst.source(db).value; |
208 | const_data_for(&node) | 208 | const_data_for(&node) |
209 | } | 209 | } |
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index 1481868d0..cf3a6ccd8 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs | |||
@@ -41,8 +41,8 @@ pub trait InternDatabase: SourceDatabase { | |||
41 | fn intern_impl(&self, loc: ItemLoc<ast::ImplBlock>) -> crate::ImplId; | 41 | fn intern_impl(&self, loc: ItemLoc<ast::ImplBlock>) -> crate::ImplId; |
42 | } | 42 | } |
43 | 43 | ||
44 | #[salsa::query_group(DefDatabase2Storage)] | 44 | #[salsa::query_group(DefDatabaseStorage)] |
45 | pub trait DefDatabase2: InternDatabase + AstDatabase { | 45 | pub trait DefDatabase: InternDatabase + AstDatabase { |
46 | #[salsa::invoke(RawItems::raw_items_with_source_map_query)] | 46 | #[salsa::invoke(RawItems::raw_items_with_source_map_query)] |
47 | fn raw_items_with_source_map( | 47 | fn raw_items_with_source_map( |
48 | &self, | 48 | &self, |
diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs index 1b5c85437..69846fd1b 100644 --- a/crates/ra_hir_def/src/docs.rs +++ b/crates/ra_hir_def/src/docs.rs | |||
@@ -5,7 +5,7 @@ use std::sync::Arc; | |||
5 | use hir_expand::either::Either; | 5 | use hir_expand::either::Either; |
6 | use ra_syntax::ast; | 6 | use ra_syntax::ast; |
7 | 7 | ||
8 | use crate::{db::DefDatabase2, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup}; | 8 | use crate::{db::DefDatabase, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup}; |
9 | 9 | ||
10 | /// Holds documentation | 10 | /// Holds documentation |
11 | #[derive(Debug, Clone, PartialEq, Eq)] | 11 | #[derive(Debug, Clone, PartialEq, Eq)] |
@@ -27,7 +27,7 @@ impl Documentation { | |||
27 | } | 27 | } |
28 | 28 | ||
29 | pub(crate) fn documentation_query( | 29 | pub(crate) fn documentation_query( |
30 | db: &impl DefDatabase2, | 30 | db: &impl DefDatabase, |
31 | def: AttrDefId, | 31 | def: AttrDefId, |
32 | ) -> Option<Documentation> { | 32 | ) -> Option<Documentation> { |
33 | match def { | 33 | match def { |
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 9e2e4c3cc..015fe772e 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs | |||
@@ -8,7 +8,7 @@ use hir_expand::name::{self, AsName, Name}; | |||
8 | use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner}; | 8 | use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner}; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | db::DefDatabase2, | 11 | db::DefDatabase, |
12 | type_ref::{TypeBound, TypeRef}, | 12 | type_ref::{TypeBound, TypeRef}, |
13 | AdtId, AstItemDef, ContainerId, GenericDefId, HasSource, Lookup, | 13 | AdtId, AstItemDef, ContainerId, GenericDefId, HasSource, Lookup, |
14 | }; | 14 | }; |
@@ -42,7 +42,7 @@ pub struct WherePredicate { | |||
42 | 42 | ||
43 | impl GenericParams { | 43 | impl GenericParams { |
44 | pub(crate) fn generic_params_query( | 44 | pub(crate) fn generic_params_query( |
45 | db: &impl DefDatabase2, | 45 | db: &impl DefDatabase, |
46 | def: GenericDefId, | 46 | def: GenericDefId, |
47 | ) -> Arc<GenericParams> { | 47 | ) -> Arc<GenericParams> { |
48 | let parent_generics = parent_generic_def(db, def).map(|it| db.generic_params(it)); | 48 | let parent_generics = parent_generic_def(db, def).map(|it| db.generic_params(it)); |
@@ -50,7 +50,7 @@ impl GenericParams { | |||
50 | } | 50 | } |
51 | 51 | ||
52 | fn new( | 52 | fn new( |
53 | db: &impl DefDatabase2, | 53 | db: &impl DefDatabase, |
54 | def: GenericDefId, | 54 | def: GenericDefId, |
55 | parent_params: Option<Arc<GenericParams>>, | 55 | parent_params: Option<Arc<GenericParams>>, |
56 | ) -> GenericParams { | 56 | ) -> GenericParams { |
@@ -168,7 +168,7 @@ impl GenericParams { | |||
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | fn parent_generic_def(db: &impl DefDatabase2, def: GenericDefId) -> Option<GenericDefId> { | 171 | fn parent_generic_def(db: &impl DefDatabase, def: GenericDefId) -> Option<GenericDefId> { |
172 | let container = match def { | 172 | let container = match def { |
173 | GenericDefId::FunctionId(it) => it.lookup(db).container, | 173 | GenericDefId::FunctionId(it) => it.lookup(db).container, |
174 | GenericDefId::TypeAliasId(it) => it.lookup(db).container, | 174 | GenericDefId::TypeAliasId(it) => it.lookup(db).container, |
diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs index 4c1a764ea..df951c533 100644 --- a/crates/ra_hir_def/src/lang_item.rs +++ b/crates/ra_hir_def/src/lang_item.rs | |||
@@ -8,7 +8,7 @@ use ra_syntax::SmolStr; | |||
8 | use rustc_hash::FxHashMap; | 8 | use rustc_hash::FxHashMap; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | db::DefDatabase2, AdtId, AttrDefId, CrateId, EnumId, FunctionId, ImplId, ModuleDefId, ModuleId, | 11 | db::DefDatabase, AdtId, AttrDefId, CrateId, EnumId, FunctionId, ImplId, ModuleDefId, ModuleId, |
12 | StaticId, StructId, TraitId, | 12 | StaticId, StructId, TraitId, |
13 | }; | 13 | }; |
14 | 14 | ||
@@ -33,7 +33,7 @@ impl LangItems { | |||
33 | } | 33 | } |
34 | 34 | ||
35 | /// Salsa query. This will look for lang items in a specific crate. | 35 | /// Salsa query. This will look for lang items in a specific crate. |
36 | pub(crate) fn crate_lang_items_query(db: &impl DefDatabase2, krate: CrateId) -> Arc<LangItems> { | 36 | pub(crate) fn crate_lang_items_query(db: &impl DefDatabase, krate: CrateId) -> Arc<LangItems> { |
37 | let mut lang_items = LangItems::default(); | 37 | let mut lang_items = LangItems::default(); |
38 | 38 | ||
39 | let crate_def_map = db.crate_def_map(krate); | 39 | let crate_def_map = db.crate_def_map(krate); |
@@ -47,7 +47,7 @@ impl LangItems { | |||
47 | } | 47 | } |
48 | 48 | ||
49 | pub(crate) fn module_lang_items_query( | 49 | pub(crate) fn module_lang_items_query( |
50 | db: &impl DefDatabase2, | 50 | db: &impl DefDatabase, |
51 | module: ModuleId, | 51 | module: ModuleId, |
52 | ) -> Option<Arc<LangItems>> { | 52 | ) -> Option<Arc<LangItems>> { |
53 | let mut lang_items = LangItems::default(); | 53 | let mut lang_items = LangItems::default(); |
@@ -62,7 +62,7 @@ impl LangItems { | |||
62 | /// Salsa query. Look for a lang item, starting from the specified crate and recursively | 62 | /// Salsa query. Look for a lang item, starting from the specified crate and recursively |
63 | /// traversing its dependencies. | 63 | /// traversing its dependencies. |
64 | pub(crate) fn lang_item_query( | 64 | pub(crate) fn lang_item_query( |
65 | db: &impl DefDatabase2, | 65 | db: &impl DefDatabase, |
66 | start_crate: CrateId, | 66 | start_crate: CrateId, |
67 | item: SmolStr, | 67 | item: SmolStr, |
68 | ) -> Option<LangItemTarget> { | 68 | ) -> Option<LangItemTarget> { |
@@ -76,7 +76,7 @@ impl LangItems { | |||
76 | .find_map(|dep| db.lang_item(dep.crate_id, item.clone())) | 76 | .find_map(|dep| db.lang_item(dep.crate_id, item.clone())) |
77 | } | 77 | } |
78 | 78 | ||
79 | fn collect_lang_items(&mut self, db: &impl DefDatabase2, module: ModuleId) { | 79 | fn collect_lang_items(&mut self, db: &impl DefDatabase, module: ModuleId) { |
80 | // Look for impl targets | 80 | // Look for impl targets |
81 | let def_map = db.crate_def_map(module.krate); | 81 | let def_map = db.crate_def_map(module.krate); |
82 | let module_data = &def_map[module.module_id]; | 82 | let module_data = &def_map[module.module_id]; |
@@ -106,7 +106,7 @@ impl LangItems { | |||
106 | 106 | ||
107 | fn collect_lang_item<T>( | 107 | fn collect_lang_item<T>( |
108 | &mut self, | 108 | &mut self, |
109 | db: &impl DefDatabase2, | 109 | db: &impl DefDatabase, |
110 | item: T, | 110 | item: T, |
111 | constructor: fn(T) -> LangItemTarget, | 111 | constructor: fn(T) -> LangItemTarget, |
112 | ) where | 112 | ) where |
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 1ba7c7ee3..1b2bc6f45 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -48,7 +48,7 @@ pub enum ModuleSource { | |||
48 | 48 | ||
49 | impl ModuleSource { | 49 | impl ModuleSource { |
50 | pub fn new( | 50 | pub fn new( |
51 | db: &impl db::DefDatabase2, | 51 | db: &impl db::DefDatabase, |
52 | file_id: Option<FileId>, | 52 | file_id: Option<FileId>, |
53 | decl_id: Option<AstId<ast::Module>>, | 53 | decl_id: Option<AstId<ast::Module>>, |
54 | ) -> ModuleSource { | 54 | ) -> ModuleSource { |
@@ -67,10 +67,7 @@ impl ModuleSource { | |||
67 | } | 67 | } |
68 | 68 | ||
69 | // FIXME: this methods do not belong here | 69 | // FIXME: this methods do not belong here |
70 | pub fn from_position( | 70 | pub fn from_position(db: &impl db::DefDatabase, position: ra_db::FilePosition) -> ModuleSource { |
71 | db: &impl db::DefDatabase2, | ||
72 | position: ra_db::FilePosition, | ||
73 | ) -> ModuleSource { | ||
74 | let parse = db.parse(position.file_id); | 71 | let parse = db.parse(position.file_id); |
75 | match &ra_syntax::algo::find_node_at_offset::<ast::Module>( | 72 | match &ra_syntax::algo::find_node_at_offset::<ast::Module>( |
76 | parse.tree().syntax(), | 73 | parse.tree().syntax(), |
@@ -84,7 +81,7 @@ impl ModuleSource { | |||
84 | } | 81 | } |
85 | } | 82 | } |
86 | 83 | ||
87 | pub fn from_child_node(db: &impl db::DefDatabase2, child: Source<&SyntaxNode>) -> ModuleSource { | 84 | pub fn from_child_node(db: &impl db::DefDatabase, child: Source<&SyntaxNode>) -> ModuleSource { |
88 | if let Some(m) = | 85 | if let Some(m) = |
89 | child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) | 86 | child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) |
90 | { | 87 | { |
@@ -96,7 +93,7 @@ impl ModuleSource { | |||
96 | } | 93 | } |
97 | } | 94 | } |
98 | 95 | ||
99 | pub fn from_file_id(db: &impl db::DefDatabase2, file_id: FileId) -> ModuleSource { | 96 | pub fn from_file_id(db: &impl db::DefDatabase, file_id: FileId) -> ModuleSource { |
100 | let source_file = db.parse(file_id).tree(); | 97 | let source_file = db.parse(file_id).tree(); |
101 | ModuleSource::SourceFile(source_file) | 98 | ModuleSource::SourceFile(source_file) |
102 | } | 99 | } |
@@ -211,14 +208,14 @@ pub struct FunctionLoc { | |||
211 | 208 | ||
212 | impl Intern for FunctionLoc { | 209 | impl Intern for FunctionLoc { |
213 | type ID = FunctionId; | 210 | type ID = FunctionId; |
214 | fn intern(self, db: &impl db::DefDatabase2) -> FunctionId { | 211 | fn intern(self, db: &impl db::DefDatabase) -> FunctionId { |
215 | db.intern_function(self) | 212 | db.intern_function(self) |
216 | } | 213 | } |
217 | } | 214 | } |
218 | 215 | ||
219 | impl Lookup for FunctionId { | 216 | impl Lookup for FunctionId { |
220 | type Data = FunctionLoc; | 217 | type Data = FunctionLoc; |
221 | fn lookup(&self, db: &impl db::DefDatabase2) -> FunctionLoc { | 218 | fn lookup(&self, db: &impl db::DefDatabase) -> FunctionLoc { |
222 | db.lookup_intern_function(*self) | 219 | db.lookup_intern_function(*self) |
223 | } | 220 | } |
224 | } | 221 | } |
@@ -301,14 +298,14 @@ pub struct ConstLoc { | |||
301 | 298 | ||
302 | impl Intern for ConstLoc { | 299 | impl Intern for ConstLoc { |
303 | type ID = ConstId; | 300 | type ID = ConstId; |
304 | fn intern(self, db: &impl db::DefDatabase2) -> ConstId { | 301 | fn intern(self, db: &impl db::DefDatabase) -> ConstId { |
305 | db.intern_const(self) | 302 | db.intern_const(self) |
306 | } | 303 | } |
307 | } | 304 | } |
308 | 305 | ||
309 | impl Lookup for ConstId { | 306 | impl Lookup for ConstId { |
310 | type Data = ConstLoc; | 307 | type Data = ConstLoc; |
311 | fn lookup(&self, db: &impl db::DefDatabase2) -> ConstLoc { | 308 | fn lookup(&self, db: &impl db::DefDatabase) -> ConstLoc { |
312 | db.lookup_intern_const(*self) | 309 | db.lookup_intern_const(*self) |
313 | } | 310 | } |
314 | } | 311 | } |
@@ -349,14 +346,14 @@ pub struct TypeAliasLoc { | |||
349 | 346 | ||
350 | impl Intern for TypeAliasLoc { | 347 | impl Intern for TypeAliasLoc { |
351 | type ID = TypeAliasId; | 348 | type ID = TypeAliasId; |
352 | fn intern(self, db: &impl db::DefDatabase2) -> TypeAliasId { | 349 | fn intern(self, db: &impl db::DefDatabase) -> TypeAliasId { |
353 | db.intern_type_alias(self) | 350 | db.intern_type_alias(self) |
354 | } | 351 | } |
355 | } | 352 | } |
356 | 353 | ||
357 | impl Lookup for TypeAliasId { | 354 | impl Lookup for TypeAliasId { |
358 | type Data = TypeAliasLoc; | 355 | type Data = TypeAliasLoc; |
359 | fn lookup(&self, db: &impl db::DefDatabase2) -> TypeAliasLoc { | 356 | fn lookup(&self, db: &impl db::DefDatabase) -> TypeAliasLoc { |
360 | db.lookup_intern_type_alias(*self) | 357 | db.lookup_intern_type_alias(*self) |
361 | } | 358 | } |
362 | } | 359 | } |
@@ -510,20 +507,20 @@ impl_froms!( | |||
510 | 507 | ||
511 | trait Intern { | 508 | trait Intern { |
512 | type ID; | 509 | type ID; |
513 | fn intern(self, db: &impl db::DefDatabase2) -> Self::ID; | 510 | fn intern(self, db: &impl db::DefDatabase) -> Self::ID; |
514 | } | 511 | } |
515 | 512 | ||
516 | pub trait Lookup { | 513 | pub trait Lookup { |
517 | type Data; | 514 | type Data; |
518 | fn lookup(&self, db: &impl db::DefDatabase2) -> Self::Data; | 515 | fn lookup(&self, db: &impl db::DefDatabase) -> Self::Data; |
519 | } | 516 | } |
520 | 517 | ||
521 | pub trait HasModule { | 518 | pub trait HasModule { |
522 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId; | 519 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId; |
523 | } | 520 | } |
524 | 521 | ||
525 | impl HasModule for FunctionLoc { | 522 | impl HasModule for FunctionLoc { |
526 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { | 523 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { |
527 | match self.container { | 524 | match self.container { |
528 | ContainerId::ModuleId(it) => it, | 525 | ContainerId::ModuleId(it) => it, |
529 | ContainerId::ImplId(it) => it.module(db), | 526 | ContainerId::ImplId(it) => it.module(db), |
@@ -533,7 +530,7 @@ impl HasModule for FunctionLoc { | |||
533 | } | 530 | } |
534 | 531 | ||
535 | impl HasModule for TypeAliasLoc { | 532 | impl HasModule for TypeAliasLoc { |
536 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { | 533 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { |
537 | match self.container { | 534 | match self.container { |
538 | ContainerId::ModuleId(it) => it, | 535 | ContainerId::ModuleId(it) => it, |
539 | ContainerId::ImplId(it) => it.module(db), | 536 | ContainerId::ImplId(it) => it.module(db), |
@@ -543,7 +540,7 @@ impl HasModule for TypeAliasLoc { | |||
543 | } | 540 | } |
544 | 541 | ||
545 | impl HasModule for ConstLoc { | 542 | impl HasModule for ConstLoc { |
546 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { | 543 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { |
547 | match self.container { | 544 | match self.container { |
548 | ContainerId::ModuleId(it) => it, | 545 | ContainerId::ModuleId(it) => it, |
549 | ContainerId::ImplId(it) => it.module(db), | 546 | ContainerId::ImplId(it) => it.module(db), |
@@ -554,13 +551,13 @@ impl HasModule for ConstLoc { | |||
554 | 551 | ||
555 | pub trait HasSource { | 552 | pub trait HasSource { |
556 | type Value; | 553 | type Value; |
557 | fn source(&self, db: &impl db::DefDatabase2) -> Source<Self::Value>; | 554 | fn source(&self, db: &impl db::DefDatabase) -> Source<Self::Value>; |
558 | } | 555 | } |
559 | 556 | ||
560 | impl HasSource for FunctionLoc { | 557 | impl HasSource for FunctionLoc { |
561 | type Value = ast::FnDef; | 558 | type Value = ast::FnDef; |
562 | 559 | ||
563 | fn source(&self, db: &impl db::DefDatabase2) -> Source<ast::FnDef> { | 560 | fn source(&self, db: &impl db::DefDatabase) -> Source<ast::FnDef> { |
564 | let node = self.ast_id.to_node(db); | 561 | let node = self.ast_id.to_node(db); |
565 | Source::new(self.ast_id.file_id(), node) | 562 | Source::new(self.ast_id.file_id(), node) |
566 | } | 563 | } |
@@ -569,7 +566,7 @@ impl HasSource for FunctionLoc { | |||
569 | impl HasSource for TypeAliasLoc { | 566 | impl HasSource for TypeAliasLoc { |
570 | type Value = ast::TypeAliasDef; | 567 | type Value = ast::TypeAliasDef; |
571 | 568 | ||
572 | fn source(&self, db: &impl db::DefDatabase2) -> Source<ast::TypeAliasDef> { | 569 | fn source(&self, db: &impl db::DefDatabase) -> Source<ast::TypeAliasDef> { |
573 | let node = self.ast_id.to_node(db); | 570 | let node = self.ast_id.to_node(db); |
574 | Source::new(self.ast_id.file_id(), node) | 571 | Source::new(self.ast_id.file_id(), node) |
575 | } | 572 | } |
@@ -578,7 +575,7 @@ impl HasSource for TypeAliasLoc { | |||
578 | impl HasSource for ConstLoc { | 575 | impl HasSource for ConstLoc { |
579 | type Value = ast::ConstDef; | 576 | type Value = ast::ConstDef; |
580 | 577 | ||
581 | fn source(&self, db: &impl db::DefDatabase2) -> Source<ast::ConstDef> { | 578 | fn source(&self, db: &impl db::DefDatabase) -> Source<ast::ConstDef> { |
582 | let node = self.ast_id.to_node(db); | 579 | let node = self.ast_id.to_node(db); |
583 | Source::new(self.ast_id.file_id(), node) | 580 | Source::new(self.ast_id.file_id(), node) |
584 | } | 581 | } |
@@ -589,6 +586,6 @@ pub trait HasChildSource { | |||
589 | type Value; | 586 | type Value; |
590 | fn child_source( | 587 | fn child_source( |
591 | &self, | 588 | &self, |
592 | db: &impl db::DefDatabase2, | 589 | db: &impl db::DefDatabase, |
593 | ) -> Source<ArenaMap<Self::ChildId, Self::Value>>; | 590 | ) -> Source<ArenaMap<Self::ChildId, Self::Value>>; |
594 | } | 591 | } |
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 6723465a5..101203b7b 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -71,7 +71,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; | |||
71 | 71 | ||
72 | use crate::{ | 72 | use crate::{ |
73 | builtin_type::BuiltinType, | 73 | builtin_type::BuiltinType, |
74 | db::DefDatabase2, | 74 | db::DefDatabase, |
75 | nameres::{ | 75 | nameres::{ |
76 | diagnostics::DefDiagnostic, path_resolution::ResolveMode, per_ns::PerNs, raw::ImportId, | 76 | diagnostics::DefDiagnostic, path_resolution::ResolveMode, per_ns::PerNs, raw::ImportId, |
77 | }, | 77 | }, |
@@ -220,7 +220,7 @@ impl CrateDefMap { | |||
220 | pub(crate) fn crate_def_map_query( | 220 | pub(crate) fn crate_def_map_query( |
221 | // Note that this doesn't have `+ AstDatabase`! | 221 | // Note that this doesn't have `+ AstDatabase`! |
222 | // This gurantess that `CrateDefMap` is stable across reparses. | 222 | // This gurantess that `CrateDefMap` is stable across reparses. |
223 | db: &impl DefDatabase2, | 223 | db: &impl DefDatabase, |
224 | krate: CrateId, | 224 | krate: CrateId, |
225 | ) -> Arc<CrateDefMap> { | 225 | ) -> Arc<CrateDefMap> { |
226 | let _p = profile("crate_def_map_query"); | 226 | let _p = profile("crate_def_map_query"); |
@@ -262,7 +262,7 @@ impl CrateDefMap { | |||
262 | 262 | ||
263 | pub fn add_diagnostics( | 263 | pub fn add_diagnostics( |
264 | &self, | 264 | &self, |
265 | db: &impl DefDatabase2, | 265 | db: &impl DefDatabase, |
266 | module: CrateModuleId, | 266 | module: CrateModuleId, |
267 | sink: &mut DiagnosticSink, | 267 | sink: &mut DiagnosticSink, |
268 | ) { | 268 | ) { |
@@ -271,7 +271,7 @@ impl CrateDefMap { | |||
271 | 271 | ||
272 | pub fn resolve_path( | 272 | pub fn resolve_path( |
273 | &self, | 273 | &self, |
274 | db: &impl DefDatabase2, | 274 | db: &impl DefDatabase, |
275 | original_module: CrateModuleId, | 275 | original_module: CrateModuleId, |
276 | path: &Path, | 276 | path: &Path, |
277 | ) -> (PerNs, Option<usize>) { | 277 | ) -> (PerNs, Option<usize>) { |
@@ -295,7 +295,7 @@ impl ModuleData { | |||
295 | /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. | 295 | /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. |
296 | pub fn definition_source( | 296 | pub fn definition_source( |
297 | &self, | 297 | &self, |
298 | db: &impl DefDatabase2, | 298 | db: &impl DefDatabase, |
299 | ) -> Source<Either<ast::SourceFile, ast::Module>> { | 299 | ) -> Source<Either<ast::SourceFile, ast::Module>> { |
300 | if let Some(file_id) = self.definition { | 300 | if let Some(file_id) = self.definition { |
301 | let sf = db.parse(file_id).tree(); | 301 | let sf = db.parse(file_id).tree(); |
@@ -307,7 +307,7 @@ impl ModuleData { | |||
307 | 307 | ||
308 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. | 308 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. |
309 | /// `None` for the crate root. | 309 | /// `None` for the crate root. |
310 | pub fn declaration_source(&self, db: &impl DefDatabase2) -> Option<Source<ast::Module>> { | 310 | pub fn declaration_source(&self, db: &impl DefDatabase) -> Option<Source<ast::Module>> { |
311 | let decl = self.declaration?; | 311 | let decl = self.declaration?; |
312 | let value = decl.to_node(db); | 312 | let value = decl.to_node(db); |
313 | Some(Source { file_id: decl.file_id(), value }) | 313 | Some(Source { file_id: decl.file_id(), value }) |
@@ -319,7 +319,7 @@ mod diagnostics { | |||
319 | use ra_db::RelativePathBuf; | 319 | use ra_db::RelativePathBuf; |
320 | use ra_syntax::{ast, AstPtr}; | 320 | use ra_syntax::{ast, AstPtr}; |
321 | 321 | ||
322 | use crate::{db::DefDatabase2, diagnostics::UnresolvedModule, nameres::CrateModuleId, AstId}; | 322 | use crate::{db::DefDatabase, diagnostics::UnresolvedModule, nameres::CrateModuleId, AstId}; |
323 | 323 | ||
324 | #[derive(Debug, PartialEq, Eq)] | 324 | #[derive(Debug, PartialEq, Eq)] |
325 | pub(super) enum DefDiagnostic { | 325 | pub(super) enum DefDiagnostic { |
@@ -333,7 +333,7 @@ mod diagnostics { | |||
333 | impl DefDiagnostic { | 333 | impl DefDiagnostic { |
334 | pub(super) fn add_to( | 334 | pub(super) fn add_to( |
335 | &self, | 335 | &self, |
336 | db: &impl DefDatabase2, | 336 | db: &impl DefDatabase, |
337 | target_module: CrateModuleId, | 337 | target_module: CrateModuleId, |
338 | sink: &mut DiagnosticSink, | 338 | sink: &mut DiagnosticSink, |
339 | ) { | 339 | ) { |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 7902293e8..1894b072a 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -13,7 +13,7 @@ use test_utils::tested_by; | |||
13 | 13 | ||
14 | use crate::{ | 14 | use crate::{ |
15 | attr::Attrs, | 15 | attr::Attrs, |
16 | db::DefDatabase2, | 16 | db::DefDatabase, |
17 | nameres::{ | 17 | nameres::{ |
18 | diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint, | 18 | diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint, |
19 | per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode, | 19 | per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode, |
@@ -24,7 +24,7 @@ use crate::{ | |||
24 | StructOrUnionId, TraitId, TypeAliasLoc, UnionId, | 24 | StructOrUnionId, TraitId, TypeAliasLoc, UnionId, |
25 | }; | 25 | }; |
26 | 26 | ||
27 | pub(super) fn collect_defs(db: &impl DefDatabase2, mut def_map: CrateDefMap) -> CrateDefMap { | 27 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { |
28 | let crate_graph = db.crate_graph(); | 28 | let crate_graph = db.crate_graph(); |
29 | 29 | ||
30 | // populate external prelude | 30 | // populate external prelude |
@@ -108,7 +108,7 @@ struct DefCollector<'a, DB> { | |||
108 | 108 | ||
109 | impl<DB> DefCollector<'_, DB> | 109 | impl<DB> DefCollector<'_, DB> |
110 | where | 110 | where |
111 | DB: DefDatabase2, | 111 | DB: DefDatabase, |
112 | { | 112 | { |
113 | fn collect(&mut self) { | 113 | fn collect(&mut self) { |
114 | let crate_graph = self.db.crate_graph(); | 114 | let crate_graph = self.db.crate_graph(); |
@@ -530,7 +530,7 @@ struct ModCollector<'a, D> { | |||
530 | 530 | ||
531 | impl<DB> ModCollector<'_, &'_ mut DefCollector<'_, DB>> | 531 | impl<DB> ModCollector<'_, &'_ mut DefCollector<'_, DB>> |
532 | where | 532 | where |
533 | DB: DefDatabase2, | 533 | DB: DefDatabase, |
534 | { | 534 | { |
535 | fn collect(&mut self, items: &[raw::RawItem]) { | 535 | fn collect(&mut self, items: &[raw::RawItem]) { |
536 | // Note: don't assert that inserted value is fresh: it's simply not true | 536 | // Note: don't assert that inserted value is fresh: it's simply not true |
@@ -798,12 +798,12 @@ mod tests { | |||
798 | use ra_db::{fixture::WithFixture, SourceDatabase}; | 798 | use ra_db::{fixture::WithFixture, SourceDatabase}; |
799 | use rustc_hash::FxHashSet; | 799 | use rustc_hash::FxHashSet; |
800 | 800 | ||
801 | use crate::{db::DefDatabase2, test_db::TestDB}; | 801 | use crate::{db::DefDatabase, test_db::TestDB}; |
802 | 802 | ||
803 | use super::*; | 803 | use super::*; |
804 | 804 | ||
805 | fn do_collect_defs( | 805 | fn do_collect_defs( |
806 | db: &impl DefDatabase2, | 806 | db: &impl DefDatabase, |
807 | def_map: CrateDefMap, | 807 | def_map: CrateDefMap, |
808 | monitor: MacroStackMonitor, | 808 | monitor: MacroStackMonitor, |
809 | ) -> CrateDefMap { | 809 | ) -> CrateDefMap { |
diff --git a/crates/ra_hir_def/src/nameres/mod_resolution.rs b/crates/ra_hir_def/src/nameres/mod_resolution.rs index b3b1379d0..14fb8ba3a 100644 --- a/crates/ra_hir_def/src/nameres/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/mod_resolution.rs | |||
@@ -3,7 +3,7 @@ use hir_expand::name::Name; | |||
3 | use ra_db::{FileId, RelativePathBuf}; | 3 | use ra_db::{FileId, RelativePathBuf}; |
4 | use ra_syntax::SmolStr; | 4 | use ra_syntax::SmolStr; |
5 | 5 | ||
6 | use crate::{db::DefDatabase2, HirFileId}; | 6 | use crate::{db::DefDatabase, HirFileId}; |
7 | 7 | ||
8 | #[derive(Clone, Debug)] | 8 | #[derive(Clone, Debug)] |
9 | pub(super) struct ModDir { | 9 | pub(super) struct ModDir { |
@@ -40,7 +40,7 @@ impl ModDir { | |||
40 | 40 | ||
41 | pub(super) fn resolve_declaration( | 41 | pub(super) fn resolve_declaration( |
42 | &self, | 42 | &self, |
43 | db: &impl DefDatabase2, | 43 | db: &impl DefDatabase, |
44 | file_id: HirFileId, | 44 | file_id: HirFileId, |
45 | name: &Name, | 45 | name: &Name, |
46 | attr_path: Option<&SmolStr>, | 46 | attr_path: Option<&SmolStr>, |
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index 95692f826..102009ac7 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs | |||
@@ -15,7 +15,7 @@ use ra_db::Edition; | |||
15 | use test_utils::tested_by; | 15 | use test_utils::tested_by; |
16 | 16 | ||
17 | use crate::{ | 17 | use crate::{ |
18 | db::DefDatabase2, | 18 | db::DefDatabase, |
19 | nameres::{per_ns::PerNs, CrateDefMap}, | 19 | nameres::{per_ns::PerNs, CrateDefMap}, |
20 | path::{Path, PathKind}, | 20 | path::{Path, PathKind}, |
21 | AdtId, CrateModuleId, EnumVariantId, ModuleDefId, ModuleId, | 21 | AdtId, CrateModuleId, EnumVariantId, ModuleDefId, ModuleId, |
@@ -63,7 +63,7 @@ impl CrateDefMap { | |||
63 | // the result. | 63 | // the result. |
64 | pub(super) fn resolve_path_fp_with_macro( | 64 | pub(super) fn resolve_path_fp_with_macro( |
65 | &self, | 65 | &self, |
66 | db: &impl DefDatabase2, | 66 | db: &impl DefDatabase, |
67 | mode: ResolveMode, | 67 | mode: ResolveMode, |
68 | original_module: CrateModuleId, | 68 | original_module: CrateModuleId, |
69 | path: &Path, | 69 | path: &Path, |
@@ -216,7 +216,7 @@ impl CrateDefMap { | |||
216 | 216 | ||
217 | fn resolve_name_in_module( | 217 | fn resolve_name_in_module( |
218 | &self, | 218 | &self, |
219 | db: &impl DefDatabase2, | 219 | db: &impl DefDatabase, |
220 | module: CrateModuleId, | 220 | module: CrateModuleId, |
221 | name: &Name, | 221 | name: &Name, |
222 | ) -> PerNs { | 222 | ) -> PerNs { |
@@ -243,7 +243,7 @@ impl CrateDefMap { | |||
243 | from_crate_root.or(from_extern_prelude) | 243 | from_crate_root.or(from_extern_prelude) |
244 | } | 244 | } |
245 | 245 | ||
246 | fn resolve_in_prelude(&self, db: &impl DefDatabase2, name: &Name) -> PerNs { | 246 | fn resolve_in_prelude(&self, db: &impl DefDatabase, name: &Name) -> PerNs { |
247 | if let Some(prelude) = self.prelude { | 247 | if let Some(prelude) = self.prelude { |
248 | let keep; | 248 | let keep; |
249 | let def_map = if prelude.krate == self.krate { | 249 | let def_map = if prelude.krate == self.krate { |
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 55a9634f8..7618cb059 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs | |||
@@ -18,7 +18,7 @@ use test_utils::tested_by; | |||
18 | 18 | ||
19 | use crate::{ | 19 | use crate::{ |
20 | attr::{Attr, Attrs}, | 20 | attr::{Attr, Attrs}, |
21 | db::DefDatabase2, | 21 | db::DefDatabase, |
22 | path::Path, | 22 | path::Path, |
23 | FileAstId, HirFileId, ModuleSource, Source, | 23 | FileAstId, HirFileId, ModuleSource, Source, |
24 | }; | 24 | }; |
@@ -67,14 +67,14 @@ impl ImportSourceMap { | |||
67 | 67 | ||
68 | impl RawItems { | 68 | impl RawItems { |
69 | pub(crate) fn raw_items_query( | 69 | pub(crate) fn raw_items_query( |
70 | db: &(impl DefDatabase2 + AstDatabase), | 70 | db: &(impl DefDatabase + AstDatabase), |
71 | file_id: HirFileId, | 71 | file_id: HirFileId, |
72 | ) -> Arc<RawItems> { | 72 | ) -> Arc<RawItems> { |
73 | db.raw_items_with_source_map(file_id).0 | 73 | db.raw_items_with_source_map(file_id).0 |
74 | } | 74 | } |
75 | 75 | ||
76 | pub(crate) fn raw_items_with_source_map_query( | 76 | pub(crate) fn raw_items_with_source_map_query( |
77 | db: &(impl DefDatabase2 + AstDatabase), | 77 | db: &(impl DefDatabase + AstDatabase), |
78 | file_id: HirFileId, | 78 | file_id: HirFileId, |
79 | ) -> (Arc<RawItems>, Arc<ImportSourceMap>) { | 79 | ) -> (Arc<RawItems>, Arc<ImportSourceMap>) { |
80 | let mut collector = RawItemsCollector { | 80 | let mut collector = RawItemsCollector { |
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 256f7d4be..b5053ba20 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs | |||
@@ -10,7 +10,7 @@ use insta::assert_snapshot; | |||
10 | use ra_db::{fixture::WithFixture, SourceDatabase}; | 10 | use ra_db::{fixture::WithFixture, SourceDatabase}; |
11 | use test_utils::covers; | 11 | use test_utils::covers; |
12 | 12 | ||
13 | use crate::{db::DefDatabase2, nameres::*, test_db::TestDB, CrateModuleId}; | 13 | use crate::{db::DefDatabase, nameres::*, test_db::TestDB, CrateModuleId}; |
14 | 14 | ||
15 | fn def_map(fixtute: &str) -> String { | 15 | fn def_map(fixtute: &str) -> String { |
16 | let dm = compute_crate_def_map(fixtute); | 16 | let dm = compute_crate_def_map(fixtute); |
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 7b5c3ec06..48a836a20 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs | |||
@@ -11,7 +11,7 @@ use rustc_hash::FxHashSet; | |||
11 | use crate::{ | 11 | use crate::{ |
12 | body::scope::{ExprScopes, ScopeId}, | 12 | body::scope::{ExprScopes, ScopeId}, |
13 | builtin_type::BuiltinType, | 13 | builtin_type::BuiltinType, |
14 | db::DefDatabase2, | 14 | db::DefDatabase, |
15 | expr::{ExprId, PatId}, | 15 | expr::{ExprId, PatId}, |
16 | generics::GenericParams, | 16 | generics::GenericParams, |
17 | nameres::{per_ns::PerNs, CrateDefMap}, | 17 | nameres::{per_ns::PerNs, CrateDefMap}, |
@@ -87,7 +87,7 @@ pub enum ValueNs { | |||
87 | 87 | ||
88 | impl Resolver { | 88 | impl Resolver { |
89 | /// Resolve known trait from std, like `std::futures::Future` | 89 | /// Resolve known trait from std, like `std::futures::Future` |
90 | pub fn resolve_known_trait(&self, db: &impl DefDatabase2, path: &Path) -> Option<TraitId> { | 90 | pub fn resolve_known_trait(&self, db: &impl DefDatabase, path: &Path) -> Option<TraitId> { |
91 | let res = self.resolve_module_path(db, path).take_types()?; | 91 | let res = self.resolve_module_path(db, path).take_types()?; |
92 | match res { | 92 | match res { |
93 | ModuleDefId::TraitId(it) => Some(it), | 93 | ModuleDefId::TraitId(it) => Some(it), |
@@ -96,7 +96,7 @@ impl Resolver { | |||
96 | } | 96 | } |
97 | 97 | ||
98 | /// Resolve known struct from std, like `std::boxed::Box` | 98 | /// Resolve known struct from std, like `std::boxed::Box` |
99 | pub fn resolve_known_struct(&self, db: &impl DefDatabase2, path: &Path) -> Option<StructId> { | 99 | pub fn resolve_known_struct(&self, db: &impl DefDatabase, path: &Path) -> Option<StructId> { |
100 | let res = self.resolve_module_path(db, path).take_types()?; | 100 | let res = self.resolve_module_path(db, path).take_types()?; |
101 | match res { | 101 | match res { |
102 | ModuleDefId::AdtId(AdtId::StructId(it)) => Some(it), | 102 | ModuleDefId::AdtId(AdtId::StructId(it)) => Some(it), |
@@ -105,7 +105,7 @@ impl Resolver { | |||
105 | } | 105 | } |
106 | 106 | ||
107 | /// Resolve known enum from std, like `std::result::Result` | 107 | /// Resolve known enum from std, like `std::result::Result` |
108 | pub fn resolve_known_enum(&self, db: &impl DefDatabase2, path: &Path) -> Option<EnumId> { | 108 | pub fn resolve_known_enum(&self, db: &impl DefDatabase, path: &Path) -> Option<EnumId> { |
109 | let res = self.resolve_module_path(db, path).take_types()?; | 109 | let res = self.resolve_module_path(db, path).take_types()?; |
110 | match res { | 110 | match res { |
111 | ModuleDefId::AdtId(AdtId::EnumId(it)) => Some(it), | 111 | ModuleDefId::AdtId(AdtId::EnumId(it)) => Some(it), |
@@ -114,7 +114,7 @@ impl Resolver { | |||
114 | } | 114 | } |
115 | 115 | ||
116 | /// pub only for source-binder | 116 | /// pub only for source-binder |
117 | pub fn resolve_module_path(&self, db: &impl DefDatabase2, path: &Path) -> PerNs { | 117 | pub fn resolve_module_path(&self, db: &impl DefDatabase, path: &Path) -> PerNs { |
118 | let (item_map, module) = match self.module() { | 118 | let (item_map, module) = match self.module() { |
119 | Some(it) => it, | 119 | Some(it) => it, |
120 | None => return PerNs::none(), | 120 | None => return PerNs::none(), |
@@ -128,7 +128,7 @@ impl Resolver { | |||
128 | 128 | ||
129 | pub fn resolve_path_in_type_ns( | 129 | pub fn resolve_path_in_type_ns( |
130 | &self, | 130 | &self, |
131 | db: &impl DefDatabase2, | 131 | db: &impl DefDatabase, |
132 | path: &Path, | 132 | path: &Path, |
133 | ) -> Option<(TypeNs, Option<usize>)> { | 133 | ) -> Option<(TypeNs, Option<usize>)> { |
134 | if path.is_type_relative() { | 134 | if path.is_type_relative() { |
@@ -184,7 +184,7 @@ impl Resolver { | |||
184 | 184 | ||
185 | pub fn resolve_path_in_type_ns_fully( | 185 | pub fn resolve_path_in_type_ns_fully( |
186 | &self, | 186 | &self, |
187 | db: &impl DefDatabase2, | 187 | db: &impl DefDatabase, |
188 | path: &Path, | 188 | path: &Path, |
189 | ) -> Option<TypeNs> { | 189 | ) -> Option<TypeNs> { |
190 | let (res, unresolved) = self.resolve_path_in_type_ns(db, path)?; | 190 | let (res, unresolved) = self.resolve_path_in_type_ns(db, path)?; |
@@ -196,7 +196,7 @@ impl Resolver { | |||
196 | 196 | ||
197 | pub fn resolve_path_in_value_ns<'p>( | 197 | pub fn resolve_path_in_value_ns<'p>( |
198 | &self, | 198 | &self, |
199 | db: &impl DefDatabase2, | 199 | db: &impl DefDatabase, |
200 | path: &'p Path, | 200 | path: &'p Path, |
201 | ) -> Option<ResolveValueResult> { | 201 | ) -> Option<ResolveValueResult> { |
202 | if path.is_type_relative() { | 202 | if path.is_type_relative() { |
@@ -296,7 +296,7 @@ impl Resolver { | |||
296 | 296 | ||
297 | pub fn resolve_path_in_value_ns_fully( | 297 | pub fn resolve_path_in_value_ns_fully( |
298 | &self, | 298 | &self, |
299 | db: &impl DefDatabase2, | 299 | db: &impl DefDatabase, |
300 | path: &Path, | 300 | path: &Path, |
301 | ) -> Option<ValueNs> { | 301 | ) -> Option<ValueNs> { |
302 | match self.resolve_path_in_value_ns(db, path)? { | 302 | match self.resolve_path_in_value_ns(db, path)? { |
@@ -305,18 +305,18 @@ impl Resolver { | |||
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | pub fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option<MacroDefId> { | 308 | pub fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> { |
309 | let (item_map, module) = self.module()?; | 309 | let (item_map, module) = self.module()?; |
310 | item_map.resolve_path(db, module, path).0.get_macros() | 310 | item_map.resolve_path(db, module, path).0.get_macros() |
311 | } | 311 | } |
312 | 312 | ||
313 | pub fn process_all_names(&self, db: &impl DefDatabase2, f: &mut dyn FnMut(Name, ScopeDef)) { | 313 | pub fn process_all_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { |
314 | for scope in self.scopes.iter().rev() { | 314 | for scope in self.scopes.iter().rev() { |
315 | scope.process_names(db, f); | 315 | scope.process_names(db, f); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | pub fn traits_in_scope(&self, db: &impl DefDatabase2) -> FxHashSet<TraitId> { | 319 | pub fn traits_in_scope(&self, db: &impl DefDatabase) -> FxHashSet<TraitId> { |
320 | let mut traits = FxHashSet::default(); | 320 | let mut traits = FxHashSet::default(); |
321 | for scope in &self.scopes { | 321 | for scope in &self.scopes { |
322 | if let Scope::ModuleScope(m) = scope { | 322 | if let Scope::ModuleScope(m) = scope { |
@@ -378,7 +378,7 @@ pub enum ScopeDef { | |||
378 | } | 378 | } |
379 | 379 | ||
380 | impl Scope { | 380 | impl Scope { |
381 | fn process_names(&self, db: &impl DefDatabase2, f: &mut dyn FnMut(Name, ScopeDef)) { | 381 | fn process_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { |
382 | match self { | 382 | match self { |
383 | Scope::ModuleScope(m) => { | 383 | Scope::ModuleScope(m) => { |
384 | // FIXME: should we provide `self` here? | 384 | // FIXME: should we provide `self` here? |
@@ -425,17 +425,13 @@ impl Scope { | |||
425 | } | 425 | } |
426 | 426 | ||
427 | // needs arbitrary_self_types to be a method... or maybe move to the def? | 427 | // needs arbitrary_self_types to be a method... or maybe move to the def? |
428 | pub fn resolver_for_expr( | 428 | pub fn resolver_for_expr(db: &impl DefDatabase, owner: DefWithBodyId, expr_id: ExprId) -> Resolver { |
429 | db: &impl DefDatabase2, | ||
430 | owner: DefWithBodyId, | ||
431 | expr_id: ExprId, | ||
432 | ) -> Resolver { | ||
433 | let scopes = db.expr_scopes(owner); | 429 | let scopes = db.expr_scopes(owner); |
434 | resolver_for_scope(db, owner, scopes.scope_for(expr_id)) | 430 | resolver_for_scope(db, owner, scopes.scope_for(expr_id)) |
435 | } | 431 | } |
436 | 432 | ||
437 | pub fn resolver_for_scope( | 433 | pub fn resolver_for_scope( |
438 | db: &impl DefDatabase2, | 434 | db: &impl DefDatabase, |
439 | owner: DefWithBodyId, | 435 | owner: DefWithBodyId, |
440 | scope_id: Option<ScopeId>, | 436 | scope_id: Option<ScopeId>, |
441 | ) -> Resolver { | 437 | ) -> Resolver { |
@@ -454,7 +450,7 @@ impl Resolver { | |||
454 | self | 450 | self |
455 | } | 451 | } |
456 | 452 | ||
457 | fn push_generic_params_scope(self, db: &impl DefDatabase2, def: GenericDefId) -> Resolver { | 453 | fn push_generic_params_scope(self, db: &impl DefDatabase, def: GenericDefId) -> Resolver { |
458 | let params = db.generic_params(def); | 454 | let params = db.generic_params(def); |
459 | if params.params.is_empty() { | 455 | if params.params.is_empty() { |
460 | self | 456 | self |
@@ -487,24 +483,24 @@ impl Resolver { | |||
487 | 483 | ||
488 | pub trait HasResolver { | 484 | pub trait HasResolver { |
489 | /// Builds a resolver for type references inside this def. | 485 | /// Builds a resolver for type references inside this def. |
490 | fn resolver(self, db: &impl DefDatabase2) -> Resolver; | 486 | fn resolver(self, db: &impl DefDatabase) -> Resolver; |
491 | } | 487 | } |
492 | 488 | ||
493 | impl HasResolver for ModuleId { | 489 | impl HasResolver for ModuleId { |
494 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 490 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
495 | let def_map = db.crate_def_map(self.krate); | 491 | let def_map = db.crate_def_map(self.krate); |
496 | Resolver::default().push_module_scope(def_map, self.module_id) | 492 | Resolver::default().push_module_scope(def_map, self.module_id) |
497 | } | 493 | } |
498 | } | 494 | } |
499 | 495 | ||
500 | impl HasResolver for TraitId { | 496 | impl HasResolver for TraitId { |
501 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 497 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
502 | self.module(db).resolver(db).push_generic_params_scope(db, self.into()) | 498 | self.module(db).resolver(db).push_generic_params_scope(db, self.into()) |
503 | } | 499 | } |
504 | } | 500 | } |
505 | 501 | ||
506 | impl<T: Into<AdtId>> HasResolver for T { | 502 | impl<T: Into<AdtId>> HasResolver for T { |
507 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 503 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
508 | let def = self.into(); | 504 | let def = self.into(); |
509 | let module = match def { | 505 | let module = match def { |
510 | AdtId::StructId(it) => it.0.module(db), | 506 | AdtId::StructId(it) => it.0.module(db), |
@@ -520,13 +516,13 @@ impl<T: Into<AdtId>> HasResolver for T { | |||
520 | } | 516 | } |
521 | 517 | ||
522 | impl HasResolver for FunctionId { | 518 | impl HasResolver for FunctionId { |
523 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 519 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
524 | self.lookup(db).container.resolver(db).push_generic_params_scope(db, self.into()) | 520 | self.lookup(db).container.resolver(db).push_generic_params_scope(db, self.into()) |
525 | } | 521 | } |
526 | } | 522 | } |
527 | 523 | ||
528 | impl HasResolver for DefWithBodyId { | 524 | impl HasResolver for DefWithBodyId { |
529 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 525 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
530 | match self { | 526 | match self { |
531 | DefWithBodyId::ConstId(c) => c.resolver(db), | 527 | DefWithBodyId::ConstId(c) => c.resolver(db), |
532 | DefWithBodyId::FunctionId(f) => f.resolver(db), | 528 | DefWithBodyId::FunctionId(f) => f.resolver(db), |
@@ -536,25 +532,25 @@ impl HasResolver for DefWithBodyId { | |||
536 | } | 532 | } |
537 | 533 | ||
538 | impl HasResolver for ConstId { | 534 | impl HasResolver for ConstId { |
539 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 535 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
540 | self.lookup(db).container.resolver(db) | 536 | self.lookup(db).container.resolver(db) |
541 | } | 537 | } |
542 | } | 538 | } |
543 | 539 | ||
544 | impl HasResolver for StaticId { | 540 | impl HasResolver for StaticId { |
545 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 541 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
546 | self.module(db).resolver(db) | 542 | self.module(db).resolver(db) |
547 | } | 543 | } |
548 | } | 544 | } |
549 | 545 | ||
550 | impl HasResolver for TypeAliasId { | 546 | impl HasResolver for TypeAliasId { |
551 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 547 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
552 | self.lookup(db).container.resolver(db).push_generic_params_scope(db, self.into()) | 548 | self.lookup(db).container.resolver(db).push_generic_params_scope(db, self.into()) |
553 | } | 549 | } |
554 | } | 550 | } |
555 | 551 | ||
556 | impl HasResolver for ContainerId { | 552 | impl HasResolver for ContainerId { |
557 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 553 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
558 | match self { | 554 | match self { |
559 | ContainerId::TraitId(it) => it.resolver(db), | 555 | ContainerId::TraitId(it) => it.resolver(db), |
560 | ContainerId::ImplId(it) => it.resolver(db), | 556 | ContainerId::ImplId(it) => it.resolver(db), |
@@ -564,7 +560,7 @@ impl HasResolver for ContainerId { | |||
564 | } | 560 | } |
565 | 561 | ||
566 | impl HasResolver for GenericDefId { | 562 | impl HasResolver for GenericDefId { |
567 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 563 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
568 | match self { | 564 | match self { |
569 | GenericDefId::FunctionId(inner) => inner.resolver(db), | 565 | GenericDefId::FunctionId(inner) => inner.resolver(db), |
570 | GenericDefId::AdtId(adt) => adt.resolver(db), | 566 | GenericDefId::AdtId(adt) => adt.resolver(db), |
@@ -578,7 +574,7 @@ impl HasResolver for GenericDefId { | |||
578 | } | 574 | } |
579 | 575 | ||
580 | impl HasResolver for ImplId { | 576 | impl HasResolver for ImplId { |
581 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | 577 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
582 | self.module(db) | 578 | self.module(db) |
583 | .resolver(db) | 579 | .resolver(db) |
584 | .push_generic_params_scope(db, self.into()) | 580 | .push_generic_params_scope(db, self.into()) |
diff --git a/crates/ra_hir_def/src/test_db.rs b/crates/ra_hir_def/src/test_db.rs index 8ee8e40d0..439e8a412 100644 --- a/crates/ra_hir_def/src/test_db.rs +++ b/crates/ra_hir_def/src/test_db.rs | |||
@@ -12,7 +12,7 @@ use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath | |||
12 | ra_db::SourceDatabaseStorage, | 12 | ra_db::SourceDatabaseStorage, |
13 | hir_expand::db::AstDatabaseStorage, | 13 | hir_expand::db::AstDatabaseStorage, |
14 | crate::db::InternDatabaseStorage, | 14 | crate::db::InternDatabaseStorage, |
15 | crate::db::DefDatabase2Storage | 15 | crate::db::DefDatabaseStorage |
16 | )] | 16 | )] |
17 | #[derive(Debug, Default)] | 17 | #[derive(Debug, Default)] |
18 | pub struct TestDB { | 18 | pub struct TestDB { |
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index 7d35d2137..c2a9dcdd1 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -21,7 +21,7 @@ use crate::{ | |||
21 | symbol_index::SymbolsDatabaseStorage, | 21 | symbol_index::SymbolsDatabaseStorage, |
22 | hir::db::InternDatabaseStorage, | 22 | hir::db::InternDatabaseStorage, |
23 | hir::db::AstDatabaseStorage, | 23 | hir::db::AstDatabaseStorage, |
24 | hir::db::DefDatabase2Storage, | 24 | hir::db::DefDatabaseStorage, |
25 | hir::db::HirDatabaseStorage | 25 | hir::db::HirDatabaseStorage |
26 | )] | 26 | )] |
27 | #[derive(Debug)] | 27 | #[derive(Debug)] |