diff options
author | Edwin Cheng <[email protected]> | 2020-01-07 16:23:53 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-01-07 16:23:53 +0000 |
commit | 1fdee246083696df8ff0a75f845c6eee8013bddf (patch) | |
tree | f375b977e0a6ca84b4341f2d83e79ece4249d61a /crates | |
parent | 8f1792fde233799fe3335032834ee7281d78e55b (diff) |
Use src node for analyze source
Diffstat (limited to 'crates')
-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 | }) |