From e6d22187a67e762bb950de244a6ca15f3a0b0731 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Apr 2020 18:25:36 +0200 Subject: Add _token suffix to token accessors I think this makes is more clear which things are : AstNode and which are : AstToken --- crates/ra_assists/src/handlers/add_explicit_type.rs | 4 ++-- crates/ra_assists/src/handlers/add_impl.rs | 2 +- crates/ra_assists/src/handlers/add_new.rs | 2 +- crates/ra_assists/src/handlers/merge_imports.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index d86d804b2..e7dcfb44e 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs @@ -1,6 +1,6 @@ use hir::HirDisplay; use ra_syntax::{ - ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner}, + ast::{self, AstNode, AstToken, LetStmt, NameOwner, TypeAscriptionOwner}, TextRange, }; @@ -35,7 +35,7 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option { let name = pat.name()?; let name_range = name.syntax().text_range(); let stmt_range = stmt.syntax().text_range(); - let eq_range = stmt.eq_token()?.text_range(); + let eq_range = stmt.eq_token()?.syntax().text_range(); // Assist should only be applicable if cursor is between 'let' and '=' let let_range = TextRange::from_to(stmt_range.start(), eq_range.start()); let cursor_in_range = ctx.frange.range.is_subrange(&let_range); diff --git a/crates/ra_assists/src/handlers/add_impl.rs b/crates/ra_assists/src/handlers/add_impl.rs index 72a201b6d..26dfed237 100644 --- a/crates/ra_assists/src/handlers/add_impl.rs +++ b/crates/ra_assists/src/handlers/add_impl.rs @@ -42,7 +42,7 @@ pub(crate) fn add_impl(ctx: AssistCtx) -> Option { if let Some(type_params) = type_params { let lifetime_params = type_params .lifetime_params() - .filter_map(|it| it.lifetime()) + .filter_map(|it| it.lifetime_token()) .map(|it| it.text().clone()); let type_params = type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index c10397249..30360af94 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs @@ -106,7 +106,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { if let Some(type_params) = type_params { let lifetime_params = type_params .lifetime_params() - .filter_map(|it| it.lifetime()) + .filter_map(|it| it.lifetime_token()) .map(|it| it.text().clone()); let type_params = type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index f8b3ddb4e..936d50ab4 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs @@ -82,7 +82,7 @@ fn try_merge_trees(old: &ast::UseTree, new: &ast::UseTree) -> Option