diff options
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir_def/src/db.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_scope.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/raw.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/incremental.rs | 16 |
5 files changed, 18 insertions, 21 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 3cf0c66ea..e8443dde8 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -563,7 +563,8 @@ impl ExprCollector<'_> { | |||
563 | ast::ModuleItem::ImplDef(_) | 563 | ast::ModuleItem::ImplDef(_) |
564 | | ast::ModuleItem::UseItem(_) | 564 | | ast::ModuleItem::UseItem(_) |
565 | | ast::ModuleItem::ExternCrateItem(_) | 565 | | ast::ModuleItem::ExternCrateItem(_) |
566 | | ast::ModuleItem::Module(_) => continue, | 566 | | ast::ModuleItem::Module(_) |
567 | | ast::ModuleItem::MacroCall(_) => continue, | ||
567 | }; | 568 | }; |
568 | self.body.item_scope.define_def(def); | 569 | self.body.item_scope.define_def(def); |
569 | if let Some(name) = name { | 570 | if let Some(name) = name { |
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index 7f8c1ea21..5dc7395f5 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs | |||
@@ -48,6 +48,7 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> { | |||
48 | fn raw_items(&self, file_id: HirFileId) -> Arc<RawItems>; | 48 | fn raw_items(&self, file_id: HirFileId) -> Arc<RawItems>; |
49 | 49 | ||
50 | #[salsa::invoke(crate_def_map_wait)] | 50 | #[salsa::invoke(crate_def_map_wait)] |
51 | #[salsa::transparent] | ||
51 | fn crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>; | 52 | fn crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>; |
52 | 53 | ||
53 | #[salsa::invoke(CrateDefMap::crate_def_map_query)] | 54 | #[salsa::invoke(CrateDefMap::crate_def_map_query)] |
@@ -109,12 +110,6 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> { | |||
109 | fn documentation(&self, def: AttrDefId) -> Option<Documentation>; | 110 | fn documentation(&self, def: AttrDefId) -> Option<Documentation>; |
110 | } | 111 | } |
111 | 112 | ||
112 | // impl<T: DefDatabase> Upcast<dyn AstDatabase> for T { | ||
113 | // fn upcast(&self) -> &dyn AstDatabase { | ||
114 | // &*self | ||
115 | // } | ||
116 | // } | ||
117 | |||
118 | fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { | 113 | fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { |
119 | let _p = profile("crate_def_map:wait"); | 114 | let _p = profile("crate_def_map:wait"); |
120 | db.crate_def_map_query(krate) | 115 | db.crate_def_map_query(krate) |
diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index ef1aaba6f..259b9ff03 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs | |||
@@ -68,7 +68,7 @@ impl ItemScope { | |||
68 | self.impls.iter().copied() | 68 | self.impls.iter().copied() |
69 | } | 69 | } |
70 | 70 | ||
71 | pub fn visbility_of(&self, def: ModuleDefId) -> Option<Visibility> { | 71 | pub fn visibility_of(&self, def: ModuleDefId) -> Option<Visibility> { |
72 | self.name_of(ItemInNs::Types(def)) | 72 | self.name_of(ItemInNs::Types(def)) |
73 | .or_else(|| self.name_of(ItemInNs::Values(def))) | 73 | .or_else(|| self.name_of(ItemInNs::Values(def))) |
74 | .map(|(_, v)| v) | 74 | .map(|(_, v)| v) |
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 1631e87b8..8f190e7f9 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs | |||
@@ -209,11 +209,8 @@ impl RawItemsCollector { | |||
209 | current_module: Option<Idx<ModuleData>>, | 209 | current_module: Option<Idx<ModuleData>>, |
210 | body: impl ast::ModuleItemOwner, | 210 | body: impl ast::ModuleItemOwner, |
211 | ) { | 211 | ) { |
212 | for item_or_macro in body.items_with_macros() { | 212 | for item in body.items() { |
213 | match item_or_macro { | 213 | self.add_item(current_module, item) |
214 | ast::ItemOrMacro::Macro(m) => self.add_macro(current_module, m), | ||
215 | ast::ItemOrMacro::Item(item) => self.add_item(current_module, item), | ||
216 | } | ||
217 | } | 214 | } |
218 | } | 215 | } |
219 | 216 | ||
@@ -265,6 +262,10 @@ impl RawItemsCollector { | |||
265 | ast::ModuleItem::StaticDef(it) => { | 262 | ast::ModuleItem::StaticDef(it) => { |
266 | (DefKind::Static(self.source_ast_id_map.ast_id(&it)), it.name()) | 263 | (DefKind::Static(self.source_ast_id_map.ast_id(&it)), it.name()) |
267 | } | 264 | } |
265 | ast::ModuleItem::MacroCall(it) => { | ||
266 | self.add_macro(current_module, it); | ||
267 | return; | ||
268 | } | ||
268 | }; | 269 | }; |
269 | if let Some(name) = name { | 270 | if let Some(name) = name { |
270 | let name = name.as_name(); | 271 | let name = name.as_name(); |
diff --git a/crates/ra_hir_def/src/nameres/tests/incremental.rs b/crates/ra_hir_def/src/nameres/tests/incremental.rs index 83f429c29..496fc6b08 100644 --- a/crates/ra_hir_def/src/nameres/tests/incremental.rs +++ b/crates/ra_hir_def/src/nameres/tests/incremental.rs | |||
@@ -4,8 +4,8 @@ use ra_db::SourceDatabaseExt; | |||
4 | 4 | ||
5 | use super::*; | 5 | use super::*; |
6 | 6 | ||
7 | fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) { | 7 | fn check_def_map_is_not_recomputed(ra_fixture_initial: &str, ra_fixture_change: &str) { |
8 | let (mut db, pos) = TestDB::with_position(initial); | 8 | let (mut db, pos) = TestDB::with_position(ra_fixture_initial); |
9 | let krate = db.test_crate(); | 9 | let krate = db.test_crate(); |
10 | { | 10 | { |
11 | let events = db.log_executed(|| { | 11 | let events = db.log_executed(|| { |
@@ -13,7 +13,7 @@ fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) { | |||
13 | }); | 13 | }); |
14 | assert!(format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) | 14 | assert!(format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) |
15 | } | 15 | } |
16 | db.set_file_text(pos.file_id, Arc::new(file_change.to_string())); | 16 | db.set_file_text(pos.file_id, Arc::new(ra_fixture_change.to_string())); |
17 | 17 | ||
18 | { | 18 | { |
19 | let events = db.log_executed(|| { | 19 | let events = db.log_executed(|| { |
@@ -26,7 +26,7 @@ fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) { | |||
26 | #[test] | 26 | #[test] |
27 | fn typing_inside_a_function_should_not_invalidate_def_map() { | 27 | fn typing_inside_a_function_should_not_invalidate_def_map() { |
28 | check_def_map_is_not_recomputed( | 28 | check_def_map_is_not_recomputed( |
29 | " | 29 | r" |
30 | //- /lib.rs | 30 | //- /lib.rs |
31 | mod foo;<|> | 31 | mod foo;<|> |
32 | 32 | ||
@@ -41,7 +41,7 @@ fn typing_inside_a_function_should_not_invalidate_def_map() { | |||
41 | //- /foo/bar.rs | 41 | //- /foo/bar.rs |
42 | pub struct Baz; | 42 | pub struct Baz; |
43 | ", | 43 | ", |
44 | " | 44 | r" |
45 | mod foo; | 45 | mod foo; |
46 | 46 | ||
47 | use crate::foo::bar::Baz; | 47 | use crate::foo::bar::Baz; |
@@ -54,7 +54,7 @@ fn typing_inside_a_function_should_not_invalidate_def_map() { | |||
54 | #[test] | 54 | #[test] |
55 | fn adding_inner_items_should_not_invalidate_def_map() { | 55 | fn adding_inner_items_should_not_invalidate_def_map() { |
56 | check_def_map_is_not_recomputed( | 56 | check_def_map_is_not_recomputed( |
57 | " | 57 | r" |
58 | //- /lib.rs | 58 | //- /lib.rs |
59 | struct S { a: i32} | 59 | struct S { a: i32} |
60 | enum E { A } | 60 | enum E { A } |
@@ -72,7 +72,7 @@ fn adding_inner_items_should_not_invalidate_def_map() { | |||
72 | //- /foo/bar.rs | 72 | //- /foo/bar.rs |
73 | pub struct Baz; | 73 | pub struct Baz; |
74 | ", | 74 | ", |
75 | " | 75 | r" |
76 | struct S { a: i32, b: () } | 76 | struct S { a: i32, b: () } |
77 | enum E { A, B } | 77 | enum E { A, B } |
78 | trait T { | 78 | trait T { |
@@ -92,7 +92,7 @@ fn adding_inner_items_should_not_invalidate_def_map() { | |||
92 | #[test] | 92 | #[test] |
93 | fn typing_inside_a_macro_should_not_invalidate_def_map() { | 93 | fn typing_inside_a_macro_should_not_invalidate_def_map() { |
94 | let (mut db, pos) = TestDB::with_position( | 94 | let (mut db, pos) = TestDB::with_position( |
95 | " | 95 | r" |
96 | //- /lib.rs | 96 | //- /lib.rs |
97 | macro_rules! m { | 97 | macro_rules! m { |
98 | ($ident:ident) => { | 98 | ($ident:ident) => { |