diff options
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/add_impl.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/ast_editor.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/introduce_variable.rs | 5 |
3 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_assists/src/add_impl.rs b/crates/ra_assists/src/add_impl.rs index 9a0cfb4e7..59ca88468 100644 --- a/crates/ra_assists/src/add_impl.rs +++ b/crates/ra_assists/src/add_impl.rs | |||
@@ -1,3 +1,5 @@ | |||
1 | use std::fmt::Write; | ||
2 | |||
1 | use hir::db::HirDatabase; | 3 | use hir::db::HirDatabase; |
2 | use join_to_string::join; | 4 | use join_to_string::join; |
3 | use ra_syntax::{ | 5 | use ra_syntax::{ |
@@ -17,7 +19,7 @@ pub(crate) fn add_impl(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | |||
17 | let mut buf = String::new(); | 19 | let mut buf = String::new(); |
18 | buf.push_str("\n\nimpl"); | 20 | buf.push_str("\n\nimpl"); |
19 | if let Some(type_params) = &type_params { | 21 | if let Some(type_params) = &type_params { |
20 | type_params.syntax().text().push_to(&mut buf); | 22 | write!(buf, "{}", type_params.syntax()).unwrap(); |
21 | } | 23 | } |
22 | buf.push_str(" "); | 24 | buf.push_str(" "); |
23 | buf.push_str(name.text().as_str()); | 25 | buf.push_str(name.text().as_str()); |
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs index 36235eb13..ab6c347ad 100644 --- a/crates/ra_assists/src/ast_editor.rs +++ b/crates/ra_assists/src/ast_editor.rs | |||
@@ -95,7 +95,7 @@ impl AstEditor<ast::NamedFieldList> { | |||
95 | position: InsertPosition<&'_ ast::NamedField>, | 95 | position: InsertPosition<&'_ ast::NamedField>, |
96 | field: &ast::NamedField, | 96 | field: &ast::NamedField, |
97 | ) { | 97 | ) { |
98 | let is_multiline = self.ast().syntax().text().contains('\n'); | 98 | let is_multiline = self.ast().syntax().text().contains_char('\n'); |
99 | let ws; | 99 | let ws; |
100 | let space = if is_multiline { | 100 | let space = if is_multiline { |
101 | ws = tokens::WsBuilder::new(&format!( | 101 | ws = tokens::WsBuilder::new(&format!( |
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 @@ | |||
1 | use std::fmt::Write; | ||
2 | |||
1 | use hir::db::HirDatabase; | 3 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 4 | use 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()) |