mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Rename Source::ast -> Source::value
This commit is contained in:
parent
e975f6364c
commit
36e3fc9d54
43 changed files with 226 additions and 214 deletions
|
@ -12,7 +12,7 @@ pub(crate) fn original_range(db: &RootDatabase, node: Source<&SyntaxNode>) -> Fi
|
|||
None => {
|
||||
return FileRange {
|
||||
file_id: node.file_id.original_file(db),
|
||||
range: node.ast.text_range(),
|
||||
range: node.value.text_range(),
|
||||
}
|
||||
}
|
||||
Some(it) => it,
|
||||
|
@ -25,14 +25,18 @@ pub(crate) fn original_range(db: &RootDatabase, node: Source<&SyntaxNode>) -> Fi
|
|||
// *Second*, we should handle recurside macro expansions
|
||||
|
||||
let token = node
|
||||
.ast
|
||||
.value
|
||||
.descendants_with_tokens()
|
||||
.filter_map(|it| it.into_token())
|
||||
.find_map(|it| expansion.map_token_up(node.with_ast(&it)));
|
||||
|
||||
match token {
|
||||
Some(it) => FileRange { file_id: it.file_id.original_file(db), range: it.ast.text_range() },
|
||||
None => FileRange { file_id: node.file_id.original_file(db), range: node.ast.text_range() },
|
||||
Some(it) => {
|
||||
FileRange { file_id: it.file_id.original_file(db), range: it.value.text_range() }
|
||||
}
|
||||
None => {
|
||||
FileRange { file_id: node.file_id.original_file(db), range: node.value.text_range() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,13 +48,13 @@ pub(crate) fn descend_into_macros(
|
|||
let src = Source::new(file_id.into(), token);
|
||||
|
||||
successors(Some(src), |token| {
|
||||
let macro_call = token.ast.ancestors().find_map(ast::MacroCall::cast)?;
|
||||
let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?;
|
||||
let tt = macro_call.token_tree()?;
|
||||
if !token.ast.text_range().is_subrange(&tt.syntax().text_range()) {
|
||||
if !token.value.text_range().is_subrange(&tt.syntax().text_range()) {
|
||||
return None;
|
||||
}
|
||||
let source_analyzer =
|
||||
hir::SourceAnalyzer::new(db, token.with_ast(token.ast.parent()).as_ref(), None);
|
||||
hir::SourceAnalyzer::new(db, token.with_ast(token.value.parent()).as_ref(), None);
|
||||
let exp = source_analyzer.expand(db, ¯o_call)?;
|
||||
exp.map_token_down(db, token.as_ref())
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue