Provide more complete AST accessors to support usage in rustc

This commit is contained in:
Luca Barbieri 2020-04-03 21:12:09 +02:00 committed by Aleksey Kladov
parent 8595693287
commit 60f4d7bd8c
18 changed files with 433 additions and 211 deletions

View file

@ -23,7 +23,7 @@ use insta::assert_snapshot;
use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase};
use ra_syntax::{
algo,
ast::{self, AstNode},
ast::{self, AstNode, AstToken},
};
use stdx::format_to;
@ -101,7 +101,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db));
let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) {
(self_param.self_kw_token().text_range(), "self".to_string())
(self_param.self_kw().unwrap().syntax().text_range(), "self".to_string())
} else {
(src_ptr.value.range(), node.text().to_string().replace("\n", " "))
};