mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Merge pull request #2760 from edwin0cheng/fix-descend-into-macros
Use src node for analyze source in `descend_into_macros`
This commit is contained in:
commit
8317efa191
1 changed files with 3 additions and 2 deletions
|
@ -76,14 +76,15 @@ pub(crate) fn descend_into_macros(
|
||||||
) -> InFile<SyntaxToken> {
|
) -> InFile<SyntaxToken> {
|
||||||
let src = InFile::new(file_id.into(), token);
|
let src = InFile::new(file_id.into(), token);
|
||||||
|
|
||||||
|
let source_analyzer =
|
||||||
|
hir::SourceAnalyzer::new(db, src.with_value(src.value.parent()).as_ref(), None);
|
||||||
|
|
||||||
successors(Some(src), |token| {
|
successors(Some(src), |token| {
|
||||||
let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?;
|
let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?;
|
||||||
let tt = macro_call.token_tree()?;
|
let tt = macro_call.token_tree()?;
|
||||||
if !token.value.text_range().is_subrange(&tt.syntax().text_range()) {
|
if !token.value.text_range().is_subrange(&tt.syntax().text_range()) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let source_analyzer =
|
|
||||||
hir::SourceAnalyzer::new(db, token.with_value(token.value.parent()).as_ref(), None);
|
|
||||||
let exp = source_analyzer.expand(db, token.with_value(¯o_call))?;
|
let exp = source_analyzer.expand(db, token.with_value(¯o_call))?;
|
||||||
exp.map_token_down(db, token.as_ref())
|
exp.map_token_down(db, token.as_ref())
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue