diff options
author | Aleksey Kladov <[email protected]> | 2020-01-07 17:08:43 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-07 17:08:43 +0000 |
commit | 8317efa19159092430c971c9f29e611e448951c3 (patch) | |
tree | 0a895d4dfc18900626f8111f7d53b1cee321ec06 | |
parent | 5914a93106a85d28d8d3efa534917686ff40287a (diff) | |
parent | 1fdee246083696df8ff0a75f845c6eee8013bddf (diff) |
Merge pull request #2760 from edwin0cheng/fix-descend-into-macros
Use src node for analyze source in `descend_into_macros`
-rw-r--r-- | crates/ra_ide/src/expand.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/crates/ra_ide/src/expand.rs b/crates/ra_ide/src/expand.rs index 7a22bb0a4..b82259a3d 100644 --- a/crates/ra_ide/src/expand.rs +++ b/crates/ra_ide/src/expand.rs | |||
@@ -76,14 +76,15 @@ pub(crate) fn descend_into_macros( | |||
76 | ) -> InFile<SyntaxToken> { | 76 | ) -> InFile<SyntaxToken> { |
77 | let src = InFile::new(file_id.into(), token); | 77 | let src = InFile::new(file_id.into(), token); |
78 | 78 | ||
79 | let source_analyzer = | ||
80 | hir::SourceAnalyzer::new(db, src.with_value(src.value.parent()).as_ref(), None); | ||
81 | |||
79 | successors(Some(src), |token| { | 82 | successors(Some(src), |token| { |
80 | let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; | 83 | let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; |
81 | let tt = macro_call.token_tree()?; | 84 | let tt = macro_call.token_tree()?; |
82 | if !token.value.text_range().is_subrange(&tt.syntax().text_range()) { | 85 | if !token.value.text_range().is_subrange(&tt.syntax().text_range()) { |
83 | return None; | 86 | return None; |
84 | } | 87 | } |
85 | let source_analyzer = | ||
86 | hir::SourceAnalyzer::new(db, token.with_value(token.value.parent()).as_ref(), None); | ||
87 | let exp = source_analyzer.expand(db, token.with_value(¯o_call))?; | 88 | let exp = source_analyzer.expand(db, token.with_value(¯o_call))?; |
88 | exp.map_token_down(db, token.as_ref()) | 89 | exp.map_token_down(db, token.as_ref()) |
89 | }) | 90 | }) |