Rename Source::ast -> Source::value

This commit is contained in:
Aleksey Kladov 2019-11-20 09:40:36 +03:00
parent e975f6364c
commit 36e3fc9d54
43 changed files with 226 additions and 214 deletions

View file

@ -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, &macro_call)?;
exp.map_token_down(db, token.as_ref())
})