aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/introduce_variable.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-07-20 14:52:11 +0100
committerAleksey Kladov <[email protected]>2019-07-20 14:52:11 +0100
commitf6bcc2d7459a3e10090391a6f9b9a2789e9cab55 (patch)
tree742f34cb6e1e38f1e009c23405fc2d3c6a232f72 /crates/ra_assists/src/introduce_variable.rs
parent6b352ffeb346eb7c7e46e00e790c2f395907eaa6 (diff)
align SyntaxText API with upstream
Diffstat (limited to 'crates/ra_assists/src/introduce_variable.rs')
-rw-r--r--crates/ra_assists/src/introduce_variable.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/crates/ra_assists/src/introduce_variable.rs b/crates/ra_assists/src/introduce_variable.rs
index df6c58989..911de2d48 100644
--- a/crates/ra_assists/src/introduce_variable.rs
+++ b/crates/ra_assists/src/introduce_variable.rs
@@ -1,3 +1,5 @@
1use std::fmt::Write;
2
1use hir::db::HirDatabase; 3use hir::db::HirDatabase;
2use ra_syntax::{ 4use ra_syntax::{
3 ast::{self, AstNode}, 5 ast::{self, AstNode},
@@ -35,8 +37,7 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option
35 buf.push_str("let var_name = "); 37 buf.push_str("let var_name = ");
36 TextUnit::of_str("let ") 38 TextUnit::of_str("let ")
37 }; 39 };
38 40 write!(buf, "{}", expr.syntax()).unwrap();
39 expr.syntax().text().push_to(&mut buf);
40 let full_stmt = ast::ExprStmt::cast(anchor_stmt.clone()); 41 let full_stmt = ast::ExprStmt::cast(anchor_stmt.clone());
41 let is_full_stmt = if let Some(expr_stmt) = &full_stmt { 42 let is_full_stmt = if let Some(expr_stmt) = &full_stmt {
42 Some(expr.syntax().clone()) == expr_stmt.expr().map(|e| e.syntax().clone()) 43 Some(expr.syntax().clone()) == expr_stmt.expr().map(|e| e.syntax().clone())