diff options
author | Aleksey Kladov <[email protected]> | 2019-11-14 06:38:25 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-14 06:38:25 +0000 |
commit | 8c8ef1432e1891809f48ff691f949047d6527c07 (patch) | |
tree | f12b8079e783bb46275f72fe5245783ed32c986f /crates/ra_hir_def/src/body | |
parent | b3175b7077129ca4b6c52e05f0491e65617ae423 (diff) |
Rename MacroResolver -> Expander
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 1a990101f..cc4bbe11a 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -16,7 +16,7 @@ use ra_syntax::{ | |||
16 | }; | 16 | }; |
17 | 17 | ||
18 | use crate::{ | 18 | use crate::{ |
19 | body::{Body, BodySourceMap, MacroResolver, PatPtr}, | 19 | body::{Body, BodySourceMap, Expander, PatPtr}, |
20 | builtin_type::{BuiltinFloat, BuiltinInt}, | 20 | builtin_type::{BuiltinFloat, BuiltinInt}, |
21 | db::DefDatabase2, | 21 | db::DefDatabase2, |
22 | expr::{ | 22 | expr::{ |
@@ -30,14 +30,14 @@ use crate::{ | |||
30 | 30 | ||
31 | pub(super) fn lower( | 31 | pub(super) fn lower( |
32 | db: &impl DefDatabase2, | 32 | db: &impl DefDatabase2, |
33 | resolver: MacroResolver, | 33 | expander: Expander, |
34 | params: Option<ast::ParamList>, | 34 | params: Option<ast::ParamList>, |
35 | body: Option<ast::Expr>, | 35 | body: Option<ast::Expr>, |
36 | ) -> (Body, BodySourceMap) { | 36 | ) -> (Body, BodySourceMap) { |
37 | let original_file_id = resolver.current_file_id; | 37 | let original_file_id = expander.current_file_id; |
38 | 38 | ||
39 | ExprCollector { | 39 | ExprCollector { |
40 | resolver, | 40 | expander, |
41 | db, | 41 | db, |
42 | original_file_id, | 42 | original_file_id, |
43 | source_map: BodySourceMap::default(), | 43 | source_map: BodySourceMap::default(), |
@@ -53,7 +53,7 @@ pub(super) fn lower( | |||
53 | 53 | ||
54 | struct ExprCollector<DB> { | 54 | struct ExprCollector<DB> { |
55 | db: DB, | 55 | db: DB, |
56 | resolver: MacroResolver, | 56 | expander: Expander, |
57 | original_file_id: HirFileId, | 57 | original_file_id: HirFileId, |
58 | 58 | ||
59 | body: Body, | 59 | body: Body, |
@@ -100,12 +100,12 @@ where | |||
100 | fn alloc_expr(&mut self, expr: Expr, ptr: AstPtr<ast::Expr>) -> ExprId { | 100 | fn alloc_expr(&mut self, expr: Expr, ptr: AstPtr<ast::Expr>) -> ExprId { |
101 | let ptr = Either::A(ptr); | 101 | let ptr = Either::A(ptr); |
102 | let id = self.body.exprs.alloc(expr); | 102 | let id = self.body.exprs.alloc(expr); |
103 | if self.resolver.current_file_id == self.original_file_id { | 103 | if self.expander.current_file_id == self.original_file_id { |
104 | self.source_map.expr_map.insert(ptr, id); | 104 | self.source_map.expr_map.insert(ptr, id); |
105 | } | 105 | } |
106 | self.source_map | 106 | self.source_map |
107 | .expr_map_back | 107 | .expr_map_back |
108 | .insert(id, Source { file_id: self.resolver.current_file_id, ast: ptr }); | 108 | .insert(id, Source { file_id: self.expander.current_file_id, ast: ptr }); |
109 | id | 109 | id |
110 | } | 110 | } |
111 | // desugared exprs don't have ptr, that's wrong and should be fixed | 111 | // desugared exprs don't have ptr, that's wrong and should be fixed |
@@ -116,22 +116,22 @@ where | |||
116 | fn alloc_expr_field_shorthand(&mut self, expr: Expr, ptr: AstPtr<ast::RecordField>) -> ExprId { | 116 | fn alloc_expr_field_shorthand(&mut self, expr: Expr, ptr: AstPtr<ast::RecordField>) -> ExprId { |
117 | let ptr = Either::B(ptr); | 117 | let ptr = Either::B(ptr); |
118 | let id = self.body.exprs.alloc(expr); | 118 | let id = self.body.exprs.alloc(expr); |
119 | if self.resolver.current_file_id == self.original_file_id { | 119 | if self.expander.current_file_id == self.original_file_id { |
120 | self.source_map.expr_map.insert(ptr, id); | 120 | self.source_map.expr_map.insert(ptr, id); |
121 | } | 121 | } |
122 | self.source_map | 122 | self.source_map |
123 | .expr_map_back | 123 | .expr_map_back |
124 | .insert(id, Source { file_id: self.resolver.current_file_id, ast: ptr }); | 124 | .insert(id, Source { file_id: self.expander.current_file_id, ast: ptr }); |
125 | id | 125 | id |
126 | } | 126 | } |
127 | fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId { | 127 | fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId { |
128 | let id = self.body.pats.alloc(pat); | 128 | let id = self.body.pats.alloc(pat); |
129 | if self.resolver.current_file_id == self.original_file_id { | 129 | if self.expander.current_file_id == self.original_file_id { |
130 | self.source_map.pat_map.insert(ptr, id); | 130 | self.source_map.pat_map.insert(ptr, id); |
131 | } | 131 | } |
132 | self.source_map | 132 | self.source_map |
133 | .pat_map_back | 133 | .pat_map_back |
134 | .insert(id, Source { file_id: self.resolver.current_file_id, ast: ptr }); | 134 | .insert(id, Source { file_id: self.expander.current_file_id, ast: ptr }); |
135 | id | 135 | id |
136 | } | 136 | } |
137 | 137 | ||
@@ -446,21 +446,21 @@ where | |||
446 | ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), | 446 | ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), |
447 | ast::Expr::MacroCall(e) => { | 447 | ast::Expr::MacroCall(e) => { |
448 | let ast_id = AstId::new( | 448 | let ast_id = AstId::new( |
449 | self.resolver.current_file_id, | 449 | self.expander.current_file_id, |
450 | self.db.ast_id_map(self.resolver.current_file_id).ast_id(&e), | 450 | self.db.ast_id_map(self.expander.current_file_id).ast_id(&e), |
451 | ); | 451 | ); |
452 | 452 | ||
453 | if let Some(path) = e.path().and_then(|path| self.parse_path(path)) { | 453 | if let Some(path) = e.path().and_then(|path| self.parse_path(path)) { |
454 | if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) { | 454 | if let Some(def) = self.expander.resolve_path_as_macro(self.db, &path) { |
455 | let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id }); | 455 | let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id }); |
456 | let file_id = call_id.as_file(MacroFileKind::Expr); | 456 | let file_id = call_id.as_file(MacroFileKind::Expr); |
457 | if let Some(node) = self.db.parse_or_expand(file_id) { | 457 | if let Some(node) = self.db.parse_or_expand(file_id) { |
458 | if let Some(expr) = ast::Expr::cast(node) { | 458 | if let Some(expr) = ast::Expr::cast(node) { |
459 | log::debug!("macro expansion {:#?}", expr.syntax()); | 459 | log::debug!("macro expansion {:#?}", expr.syntax()); |
460 | let old_file_id = | 460 | let old_file_id = |
461 | std::mem::replace(&mut self.resolver.current_file_id, file_id); | 461 | std::mem::replace(&mut self.expander.current_file_id, file_id); |
462 | let id = self.collect_expr(expr); | 462 | let id = self.collect_expr(expr); |
463 | self.resolver.current_file_id = old_file_id; | 463 | self.expander.current_file_id = old_file_id; |
464 | return id; | 464 | return id; |
465 | } | 465 | } |
466 | } | 466 | } |
@@ -582,7 +582,7 @@ where | |||
582 | } | 582 | } |
583 | 583 | ||
584 | fn parse_path(&mut self, path: ast::Path) -> Option<Path> { | 584 | fn parse_path(&mut self, path: ast::Path) -> Option<Path> { |
585 | let hygiene = Hygiene::new(self.db, self.resolver.current_file_id); | 585 | let hygiene = Hygiene::new(self.db, self.expander.current_file_id); |
586 | Path::from_src(path, &hygiene) | 586 | Path::from_src(path, &hygiene) |
587 | } | 587 | } |
588 | } | 588 | } |