From 0a9c80053ffcd72d076ca3792bf4a9ddb94eaf95 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Wed, 20 Nov 2019 12:21:31 +0800 Subject: Fix expand macro --- crates/ra_ide_api/src/expand.rs | 2 +- crates/ra_ide_api/src/expand_macro.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/expand.rs b/crates/ra_ide_api/src/expand.rs index 0ad125a9e..2f1abf509 100644 --- a/crates/ra_ide_api/src/expand.rs +++ b/crates/ra_ide_api/src/expand.rs @@ -55,7 +55,7 @@ pub(crate) fn descend_into_macros( } let source_analyzer = hir::SourceAnalyzer::new(db, token.with_value(token.value.parent()).as_ref(), None); - let exp = source_analyzer.expand(db, ¯o_call)?; + let exp = source_analyzer.expand(db, token.with_value(¯o_call))?; exp.map_token_down(db, token.as_ref()) }) .last() diff --git a/crates/ra_ide_api/src/expand_macro.rs b/crates/ra_ide_api/src/expand_macro.rs index 2d478ec09..7f39262dc 100644 --- a/crates/ra_ide_api/src/expand_macro.rs +++ b/crates/ra_ide_api/src/expand_macro.rs @@ -23,7 +23,7 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option< let mac = name_ref.syntax().ancestors().find_map(ast::MacroCall::cast)?; let source = hir::Source::new(position.file_id.into(), mac.syntax()); - let expanded = expand_macro_recur(db, source, &mac)?; + let expanded = expand_macro_recur(db, source, source.with_value(&mac))?; // FIXME: // macro expansion may lose all white space information @@ -35,10 +35,10 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option< fn expand_macro_recur( db: &RootDatabase, source: hir::Source<&SyntaxNode>, - macro_call: &ast::MacroCall, + macro_call: hir::Source<&ast::MacroCall>, ) -> Option { let analyzer = hir::SourceAnalyzer::new(db, source, None); - let expansion = analyzer.expand(db, ¯o_call)?; + let expansion = analyzer.expand(db, macro_call)?; let macro_file_id = expansion.file_id(); let expanded: SyntaxNode = db.parse_or_expand(macro_file_id)?; @@ -46,8 +46,8 @@ fn expand_macro_recur( let mut replaces = FxHashMap::default(); for child in children.into_iter() { - let source = hir::Source::new(macro_file_id, source.value); - let new_node = expand_macro_recur(db, source, &child)?; + let node = hir::Source::new(macro_file_id, &child); + let new_node = expand_macro_recur(db, source, node)?; replaces.insert(child.syntax().clone().into(), new_node.into()); } -- cgit v1.2.3