diff options
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/expand_macro.rs | 7 |
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 | ||
3 | use crate::{db::RootDatabase, FilePosition}; | 3 | use crate::{db::RootDatabase, FilePosition}; |
4 | use hir::db::AstDatabase; | ||
4 | use ra_db::SourceDatabase; | 5 | use ra_db::SourceDatabase; |
5 | use rustc_hash::FxHashMap; | 6 | use rustc_hash::FxHashMap; |
6 | 7 | ||
7 | use hir::db::AstDatabase; | ||
8 | use ra_syntax::{ | 8 | use 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, ¯o_call)?; | 49 | let expansion = analyzer.expand(db, ¯o_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()); |