aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/expand_macro.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/expand_macro.rs b/crates/ra_ide_api/src/expand_macro.rs
index 48dc90932..49c096ed5 100644
--- a/crates/ra_ide_api/src/expand_macro.rs
+++ b/crates/ra_ide_api/src/expand_macro.rs
@@ -1,10 +1,10 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use crate::{db::RootDatabase, FilePosition}; 3use crate::{db::RootDatabase, FilePosition};
4use hir::db::AstDatabase;
4use ra_db::SourceDatabase; 5use ra_db::SourceDatabase;
5use rustc_hash::FxHashMap; 6use rustc_hash::FxHashMap;
6 7
7use hir::db::AstDatabase;
8use ra_syntax::{ 8use ra_syntax::{
9 algo::{find_node_at_offset, replace_descendants}, 9 algo::{find_node_at_offset, replace_descendants},
10 ast::{self}, 10 ast::{self},
@@ -47,13 +47,14 @@ fn expand_macro_recur(
47) -> Option<SyntaxNode> { 47) -> Option<SyntaxNode> {
48 let analyzer = hir::SourceAnalyzer::new(db, source, None); 48 let analyzer = hir::SourceAnalyzer::new(db, source, None);
49 let expansion = analyzer.expand(db, &macro_call)?; 49 let expansion = analyzer.expand(db, &macro_call)?;
50 let expanded: SyntaxNode = db.parse_or_expand(expansion.file_id())?; 50 let new_source = expansion.source(db);
51 let expanded: SyntaxNode = db.parse_or_expand(new_source.file_id)?;
51 52
52 let children = expanded.descendants().filter_map(ast::MacroCall::cast); 53 let children = expanded.descendants().filter_map(ast::MacroCall::cast);
53 let mut replaces = FxHashMap::default(); 54 let mut replaces = FxHashMap::default();
54 55
55 for child in children.into_iter() { 56 for child in children.into_iter() {
56 let source = hir::Source::new(expansion.file_id(), source.ast); 57 let source = new_source.with_ast(source.ast);
57 let new_node = expand_macro_recur(db, source, &child)?; 58 let new_node = expand_macro_recur(db, source, &child)?;
58 59
59 replaces.insert(child.syntax().clone().into(), new_node.into()); 60 replaces.insert(child.syntax().clone().into(), new_node.into());