diff options
author | Edwin Cheng <[email protected]> | 2019-11-08 01:57:01 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-11-08 02:19:41 +0000 |
commit | 62ed93db13877888379ea38c843729419bdf99d0 (patch) | |
tree | 4c5097eb65cc19861580cbc29bd2fc43486fed84 /crates/ra_hir_expand/src | |
parent | 568f3cff41fd4ef49468b60f4343755a5b7b05cb (diff) |
Refactor and add more comments
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/db.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index e2860371f..1eaf8bf30 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs | |||
@@ -148,17 +148,15 @@ pub(crate) fn parse_macro_with_info( | |||
148 | let arg_tt = loc.ast_id.to_node(db).token_tree(); | 148 | let arg_tt = loc.ast_id.to_node(db).token_tree(); |
149 | let def_tt = loc.def.ast_id.to_node(db).token_tree(); | 149 | let def_tt = loc.def.ast_id.to_node(db).token_tree(); |
150 | 150 | ||
151 | let arg_start = arg_tt.map(|t| t.syntax().text_range().start()); | 151 | let arg_range = arg_tt.map(|t| t.syntax().text_range()); |
152 | let def_start = def_tt.map(|t| t.syntax().text_range().start()); | 152 | let def_range = def_tt.map(|t| t.syntax().text_range()); |
153 | 153 | ||
154 | let shift = db.macro_def(loc.def)?.0.shift(); | 154 | let shift = db.macro_def(loc.def)?.0.shift(); |
155 | 155 | ||
156 | let arg_map = arg_start | 156 | let arg_map = |
157 | .map(|start| exp_map.map_ranges(&expand_info.arg_map, start, shift)) | 157 | arg_range.map(|it| exp_map.map_ranges(&expand_info.arg_map, it, shift)).unwrap_or_default(); |
158 | .unwrap_or_default(); | 158 | let def_map = |
159 | let def_map = def_start | 159 | def_range.map(|it| exp_map.map_ranges(&expand_info.def_map, it, 0)).unwrap_or_default(); |
160 | .map(|start| exp_map.map_ranges(&expand_info.def_map, start, 0)) | ||
161 | .unwrap_or_default(); | ||
162 | 160 | ||
163 | let info = ExpansionInfo { arg_map, def_map }; | 161 | let info = ExpansionInfo { arg_map, def_map }; |
164 | 162 | ||