aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assists
diff options
context:
space:
mode:
authorTomasKralCZ <[email protected]>2020-01-19 17:55:56 +0000
committerTomasKralCZ <[email protected]>2020-01-19 17:55:56 +0000
commitf67ee69777e53ca1121e6aa461ecf84a3c01e139 (patch)
tree808b2ca3bff4a299a4997a5f1f4847d072f0e42c /crates/ra_assists/src/assists
parent514df15d9e32e057ba23dda0d4f5c07e82e7ed23 (diff)
added eq_token() method to LetStmt
Diffstat (limited to 'crates/ra_assists/src/assists')
-rw-r--r--crates/ra_assists/src/assists/add_explicit_type.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/crates/ra_assists/src/assists/add_explicit_type.rs b/crates/ra_assists/src/assists/add_explicit_type.rs
index 713abf910..38a351a54 100644
--- a/crates/ra_assists/src/assists/add_explicit_type.rs
+++ b/crates/ra_assists/src/assists/add_explicit_type.rs
@@ -1,7 +1,6 @@
1use hir::{db::HirDatabase, HirDisplay}; 1use hir::{db::HirDatabase, HirDisplay};
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{self, AstNode, LetStmt, NameOwner}, 3 ast::{self, AstNode, LetStmt, NameOwner},
4 SyntaxKind::EQ,
5 TextRange, T, 4 TextRange, T,
6}; 5};
7 6
@@ -37,7 +36,7 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx<impl HirDatabase>) -> Option<Assi
37 let name_range = name.syntax().text_range(); 36 let name_range = name.syntax().text_range();
38 // Assist should only be applicable if cursor is between 'let' and '=' 37 // Assist should only be applicable if cursor is between 'let' and '='
39 let stmt_range = stmt.syntax().text_range(); 38 let stmt_range = stmt.syntax().text_range();
40 let eq_range = stmt.syntax().descendants_with_tokens().find(|t| t.kind() == EQ)?.text_range(); 39 let eq_range = stmt.eq_token()?.text_range();
41 let let_range = TextRange::from_to(stmt_range.start(), eq_range.start()); 40 let let_range = TextRange::from_to(stmt_range.start(), eq_range.start());
42 let cursor_in_range = ctx.frange.range.is_subrange(&let_range); 41 let cursor_in_range = ctx.frange.range.is_subrange(&let_range);
43 if !cursor_in_range { 42 if !cursor_in_range {