aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorYerkebulan Tulibergenov <[email protected]>2019-01-16 04:27:15 +0000
committerYerkebulan Tulibergenov <[email protected]>2019-01-16 04:27:15 +0000
commit4dd7ec94bc92055f09fe2aa6a8920a4e32075cef (patch)
tree23ea3c205c2df3e83d5773921449dbb3bbfa22bd /crates
parent5e35f191fc5e1055f8696c82c39cfa2a3ac70bff (diff)
use has_semi
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide_api_light/src/assists/introduce_variable.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/crates/ra_ide_api_light/src/assists/introduce_variable.rs b/crates/ra_ide_api_light/src/assists/introduce_variable.rs
index e51cb22f0..230d23039 100644
--- a/crates/ra_ide_api_light/src/assists/introduce_variable.rs
+++ b/crates/ra_ide_api_light/src/assists/introduce_variable.rs
@@ -20,16 +20,15 @@ pub fn introduce_variable<'a>(ctx: AssistCtx) -> Option<Assist> {
20 20
21 buf.push_str("let var_name = "); 21 buf.push_str("let var_name = ");
22 expr.syntax().text().push_to(&mut buf); 22 expr.syntax().text().push_to(&mut buf);
23 let is_full_stmt = if let Some(expr_stmt) = ast::ExprStmt::cast(anchor_stmt) { 23 let full_stmt = ast::ExprStmt::cast(anchor_stmt);
24 let is_full_stmt = if let Some(expr_stmt) = full_stmt {
24 Some(expr.syntax()) == expr_stmt.expr().map(|e| e.syntax()) 25 Some(expr.syntax()) == expr_stmt.expr().map(|e| e.syntax())
25 } else { 26 } else {
26 false 27 false
27 }; 28 };
28 if is_full_stmt { 29 if is_full_stmt {
29 if let Some(last_child) = expr.syntax().last_child() { 30 if !full_stmt.unwrap().has_semi() {
30 if last_child.kind() != SEMI && !is_semi_right_after(expr.syntax()) { 31 buf.push_str(";");
31 buf.push_str(";");
32 }
33 } 32 }
34 edit.replace(expr.syntax().range(), buf); 33 edit.replace(expr.syntax().range(), buf);
35 } else { 34 } else {