diff options
author | Edwin Cheng <[email protected]> | 2019-12-23 05:18:28 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-12-23 05:19:01 +0000 |
commit | 16156d766dd8a5624d9455ffded6358fe879c416 (patch) | |
tree | 5e76885085a5a566cb1f946afd20bc5d2547334e /crates/ra_hir_def/src | |
parent | 60aa4d12f95477565d5b01f122d2c9dd845015b4 (diff) |
Add macro call support for type_of
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/body.rs | 16 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 2 |
2 files changed, 7 insertions, 11 deletions
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index d3e4c50ae..8ab92b23a 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs | |||
@@ -26,7 +26,7 @@ use crate::{ | |||
26 | DefWithBodyId, HasModule, Lookup, ModuleId, | 26 | DefWithBodyId, HasModule, Lookup, ModuleId, |
27 | }; | 27 | }; |
28 | 28 | ||
29 | pub(crate) struct Expander { | 29 | pub struct Expander { |
30 | crate_def_map: Arc<CrateDefMap>, | 30 | crate_def_map: Arc<CrateDefMap>, |
31 | current_file_id: HirFileId, | 31 | current_file_id: HirFileId, |
32 | hygiene: Hygiene, | 32 | hygiene: Hygiene, |
@@ -35,18 +35,14 @@ pub(crate) struct Expander { | |||
35 | } | 35 | } |
36 | 36 | ||
37 | impl Expander { | 37 | impl Expander { |
38 | pub(crate) fn new( | 38 | pub fn new(db: &impl DefDatabase, current_file_id: HirFileId, module: ModuleId) -> Expander { |
39 | db: &impl DefDatabase, | ||
40 | current_file_id: HirFileId, | ||
41 | module: ModuleId, | ||
42 | ) -> Expander { | ||
43 | let crate_def_map = db.crate_def_map(module.krate); | 39 | let crate_def_map = db.crate_def_map(module.krate); |
44 | let hygiene = Hygiene::new(db, current_file_id); | 40 | let hygiene = Hygiene::new(db, current_file_id); |
45 | let ast_id_map = db.ast_id_map(current_file_id); | 41 | let ast_id_map = db.ast_id_map(current_file_id); |
46 | Expander { crate_def_map, current_file_id, hygiene, ast_id_map, module } | 42 | Expander { crate_def_map, current_file_id, hygiene, ast_id_map, module } |
47 | } | 43 | } |
48 | 44 | ||
49 | pub(crate) fn enter_expand<T: ast::AstNode, DB: DefDatabase>( | 45 | pub fn enter_expand<T: ast::AstNode, DB: DefDatabase>( |
50 | &mut self, | 46 | &mut self, |
51 | db: &DB, | 47 | db: &DB, |
52 | macro_call: ast::MacroCall, | 48 | macro_call: ast::MacroCall, |
@@ -84,14 +80,14 @@ impl Expander { | |||
84 | None | 80 | None |
85 | } | 81 | } |
86 | 82 | ||
87 | pub(crate) fn exit(&mut self, db: &impl DefDatabase, mut mark: Mark) { | 83 | pub fn exit(&mut self, db: &impl DefDatabase, mut mark: Mark) { |
88 | self.hygiene = Hygiene::new(db, mark.file_id); | 84 | self.hygiene = Hygiene::new(db, mark.file_id); |
89 | self.current_file_id = mark.file_id; | 85 | self.current_file_id = mark.file_id; |
90 | self.ast_id_map = mem::take(&mut mark.ast_id_map); | 86 | self.ast_id_map = mem::take(&mut mark.ast_id_map); |
91 | mark.bomb.defuse(); | 87 | mark.bomb.defuse(); |
92 | } | 88 | } |
93 | 89 | ||
94 | pub(crate) fn to_source<T>(&self, value: T) -> InFile<T> { | 90 | pub fn to_source<T>(&self, value: T) -> InFile<T> { |
95 | InFile { file_id: self.current_file_id, value } | 91 | InFile { file_id: self.current_file_id, value } |
96 | } | 92 | } |
97 | 93 | ||
@@ -116,7 +112,7 @@ impl Expander { | |||
116 | } | 112 | } |
117 | } | 113 | } |
118 | 114 | ||
119 | pub(crate) struct Mark { | 115 | pub struct Mark { |
120 | file_id: HirFileId, | 116 | file_id: HirFileId, |
121 | ast_id_map: Arc<AstIdMap>, | 117 | ast_id_map: Arc<AstIdMap>, |
122 | bomb: DropBomb, | 118 | bomb: DropBomb, |
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index f6c7f38d1..f58ce9a95 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -48,7 +48,7 @@ use ra_arena::{impl_arena_id, RawId}; | |||
48 | use ra_db::{impl_intern_key, salsa, CrateId}; | 48 | use ra_db::{impl_intern_key, salsa, CrateId}; |
49 | use ra_syntax::{ast, AstNode}; | 49 | use ra_syntax::{ast, AstNode}; |
50 | 50 | ||
51 | use crate::body::Expander; | 51 | pub use crate::body::Expander; |
52 | use crate::builtin_type::BuiltinType; | 52 | use crate::builtin_type::BuiltinType; |
53 | 53 | ||
54 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 54 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |