aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/expand.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/expand.rs')
-rw-r--r--crates/ra_ide_api/src/expand.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/expand.rs b/crates/ra_ide_api/src/expand.rs
index 7f59e46d2..0228bced9 100644
--- a/crates/ra_ide_api/src/expand.rs
+++ b/crates/ra_ide_api/src/expand.rs
@@ -12,7 +12,7 @@ pub(crate) fn original_range(db: &RootDatabase, node: Source<&SyntaxNode>) -> Fi
12 None => { 12 None => {
13 return FileRange { 13 return FileRange {
14 file_id: node.file_id.original_file(db), 14 file_id: node.file_id.original_file(db),
15 range: node.ast.text_range(), 15 range: node.value.text_range(),
16 } 16 }
17 } 17 }
18 Some(it) => it, 18 Some(it) => it,
@@ -25,14 +25,18 @@ pub(crate) fn original_range(db: &RootDatabase, node: Source<&SyntaxNode>) -> Fi
25 // *Second*, we should handle recurside macro expansions 25 // *Second*, we should handle recurside macro expansions
26 26
27 let token = node 27 let token = node
28 .ast 28 .value
29 .descendants_with_tokens() 29 .descendants_with_tokens()
30 .filter_map(|it| it.into_token()) 30 .filter_map(|it| it.into_token())
31 .find_map(|it| expansion.map_token_up(node.with_ast(&it))); 31 .find_map(|it| expansion.map_token_up(node.with_ast(&it)));
32 32
33 match token { 33 match token {
34 Some(it) => FileRange { file_id: it.file_id.original_file(db), range: it.ast.text_range() }, 34 Some(it) => {
35 None => FileRange { file_id: node.file_id.original_file(db), range: node.ast.text_range() }, 35 FileRange { file_id: it.file_id.original_file(db), range: it.value.text_range() }
36 }
37 None => {
38 FileRange { file_id: node.file_id.original_file(db), range: node.value.text_range() }
39 }
36 } 40 }
37} 41}
38 42
@@ -44,13 +48,13 @@ pub(crate) fn descend_into_macros(
44 let src = Source::new(file_id.into(), token); 48 let src = Source::new(file_id.into(), token);
45 49
46 successors(Some(src), |token| { 50 successors(Some(src), |token| {
47 let macro_call = token.ast.ancestors().find_map(ast::MacroCall::cast)?; 51 let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?;
48 let tt = macro_call.token_tree()?; 52 let tt = macro_call.token_tree()?;
49 if !token.ast.text_range().is_subrange(&tt.syntax().text_range()) { 53 if !token.value.text_range().is_subrange(&tt.syntax().text_range()) {
50 return None; 54 return None;
51 } 55 }
52 let source_analyzer = 56 let source_analyzer =
53 hir::SourceAnalyzer::new(db, token.with_ast(token.ast.parent()).as_ref(), None); 57 hir::SourceAnalyzer::new(db, token.with_ast(token.value.parent()).as_ref(), None);
54 let exp = source_analyzer.expand(db, &macro_call)?; 58 let exp = source_analyzer.expand(db, &macro_call)?;
55 exp.map_token_down(db, token.as_ref()) 59 exp.map_token_down(db, token.as_ref())
56 }) 60 })