aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/ast_editor.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-08-23 15:01:06 +0100
committerGitHub <[email protected]>2019-08-23 15:01:06 +0100
commita832a2f7dd22c93bc69a7be5d24799bb042b8129 (patch)
tree15f55b3eab48c3d0bbb1975fbd4db7cbb56d3e3e /crates/ra_assists/src/ast_editor.rs
parentc12dce0073c1766f7d2b10a69f8526a8093e70dc (diff)
parent5b18a4eef9e69260ce2f105b33553c929cb7d827 (diff)
Merge #1731
1731: rename pos_field -> tuple_field r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/ast_editor.rs')
-rw-r--r--crates/ra_assists/src/ast_editor.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs
index 076df98f2..6815638dc 100644
--- a/crates/ra_assists/src/ast_editor.rs
+++ b/crates/ra_assists/src/ast_editor.rs
@@ -93,15 +93,15 @@ impl<N: AstNode> AstEditor<N> {
93 } 93 }
94} 94}
95 95
96impl AstEditor<ast::NamedFieldList> { 96impl AstEditor<ast::RecordFieldList> {
97 pub fn append_field(&mut self, field: &ast::NamedField) { 97 pub fn append_field(&mut self, field: &ast::RecordField) {
98 self.insert_field(InsertPosition::Last, field) 98 self.insert_field(InsertPosition::Last, field)
99 } 99 }
100 100
101 pub fn insert_field( 101 pub fn insert_field(
102 &mut self, 102 &mut self,
103 position: InsertPosition<&'_ ast::NamedField>, 103 position: InsertPosition<&'_ ast::RecordField>,
104 field: &ast::NamedField, 104 field: &ast::RecordField,
105 ) { 105 ) {
106 let is_multiline = self.ast().syntax().text().contains_char('\n'); 106 let is_multiline = self.ast().syntax().text().contains_char('\n');
107 let ws; 107 let ws;
@@ -245,16 +245,16 @@ pub struct AstBuilder<N: AstNode> {
245 _phantom: std::marker::PhantomData<N>, 245 _phantom: std::marker::PhantomData<N>,
246} 246}
247 247
248impl AstBuilder<ast::NamedField> { 248impl AstBuilder<ast::RecordField> {
249 pub fn from_name(name: &Name) -> ast::NamedField { 249 pub fn from_name(name: &Name) -> ast::RecordField {
250 ast_node_from_file_text(&format!("fn f() {{ S {{ {}: (), }} }}", name)) 250 ast_node_from_file_text(&format!("fn f() {{ S {{ {}: (), }} }}", name))
251 } 251 }
252 252
253 fn from_text(text: &str) -> ast::NamedField { 253 fn from_text(text: &str) -> ast::RecordField {
254 ast_node_from_file_text(&format!("fn f() {{ S {{ {}, }} }}", text)) 254 ast_node_from_file_text(&format!("fn f() {{ S {{ {}, }} }}", text))
255 } 255 }
256 256
257 pub fn from_pieces(name: &ast::NameRef, expr: Option<&ast::Expr>) -> ast::NamedField { 257 pub fn from_pieces(name: &ast::NameRef, expr: Option<&ast::Expr>) -> ast::RecordField {
258 match expr { 258 match expr {
259 Some(expr) => Self::from_text(&format!("{}: {}", name.syntax(), expr.syntax())), 259 Some(expr) => Self::from_text(&format!("{}: {}", name.syntax(), expr.syntax())),
260 None => Self::from_text(&name.syntax().to_string()), 260 None => Self::from_text(&name.syntax().to_string()),
@@ -336,12 +336,12 @@ impl AstBuilder<ast::TupleStructPat> {
336 } 336 }
337} 337}
338 338
339impl AstBuilder<ast::StructPat> { 339impl AstBuilder<ast::RecordPat> {
340 fn from_text(text: &str) -> ast::StructPat { 340 fn from_text(text: &str) -> ast::RecordPat {
341 ast_node_from_file_text(&format!("fn f({}: ())", text)) 341 ast_node_from_file_text(&format!("fn f({}: ())", text))
342 } 342 }
343 343
344 pub fn from_pieces(path: &ast::Path, pats: impl Iterator<Item = ast::Pat>) -> ast::StructPat { 344 pub fn from_pieces(path: &ast::Path, pats: impl Iterator<Item = ast::Pat>) -> ast::RecordPat {
345 let pats_str = pats.map(|p| p.syntax().to_string()).collect::<Vec<_>>().join(", "); 345 let pats_str = pats.map(|p| p.syntax().to_string()).collect::<Vec<_>>().join(", ");
346 Self::from_text(&format!("{}{{ {} }}", path.syntax(), pats_str)) 346 Self::from_text(&format!("{}{{ {} }}", path.syntax(), pats_str))
347 } 347 }