From 5b18a4eef9e69260ce2f105b33553c929cb7d827 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 23 Aug 2019 15:55:21 +0300 Subject: rename struct -> record, pos -> tuple --- crates/ra_assists/src/ast_editor.rs | 22 +++++++++++----------- crates/ra_assists/src/change_visibility.rs | 2 +- crates/ra_assists/src/fill_match_arms.rs | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'crates/ra_assists/src') 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 AstEditor { } } -impl AstEditor { - pub fn append_field(&mut self, field: &ast::NamedField) { +impl AstEditor { + pub fn append_field(&mut self, field: &ast::RecordField) { self.insert_field(InsertPosition::Last, field) } pub fn insert_field( &mut self, - position: InsertPosition<&'_ ast::NamedField>, - field: &ast::NamedField, + position: InsertPosition<&'_ ast::RecordField>, + field: &ast::RecordField, ) { let is_multiline = self.ast().syntax().text().contains_char('\n'); let ws; @@ -245,16 +245,16 @@ pub struct AstBuilder { _phantom: std::marker::PhantomData, } -impl AstBuilder { - pub fn from_name(name: &Name) -> ast::NamedField { +impl AstBuilder { + pub fn from_name(name: &Name) -> ast::RecordField { ast_node_from_file_text(&format!("fn f() {{ S {{ {}: (), }} }}", name)) } - fn from_text(text: &str) -> ast::NamedField { + fn from_text(text: &str) -> ast::RecordField { ast_node_from_file_text(&format!("fn f() {{ S {{ {}, }} }}", text)) } - pub fn from_pieces(name: &ast::NameRef, expr: Option<&ast::Expr>) -> ast::NamedField { + pub fn from_pieces(name: &ast::NameRef, expr: Option<&ast::Expr>) -> ast::RecordField { match expr { Some(expr) => Self::from_text(&format!("{}: {}", name.syntax(), expr.syntax())), None => Self::from_text(&name.syntax().to_string()), @@ -336,12 +336,12 @@ impl AstBuilder { } } -impl AstBuilder { - fn from_text(text: &str) -> ast::StructPat { +impl AstBuilder { + fn from_text(text: &str) -> ast::RecordPat { ast_node_from_file_text(&format!("fn f({}: ())", text)) } - pub fn from_pieces(path: &ast::Path, pats: impl Iterator) -> ast::StructPat { + pub fn from_pieces(path: &ast::Path, pats: impl Iterator) -> ast::RecordPat { let pats_str = pats.map(|p| p.syntax().to_string()).collect::>().join(", "); Self::from_text(&format!("{}{{ {} }}", path.syntax(), pats_str)) } diff --git a/crates/ra_assists/src/change_visibility.rs b/crates/ra_assists/src/change_visibility.rs index d28cdd07b..60c74debc 100644 --- a/crates/ra_assists/src/change_visibility.rs +++ b/crates/ra_assists/src/change_visibility.rs @@ -38,7 +38,7 @@ fn add_vis(mut ctx: AssistCtx) -> Option { (vis_offset(&parent), keyword.text_range()) } else { let ident = ctx.token_at_offset().find(|leaf| leaf.kind() == IDENT)?; - let field = ident.parent().ancestors().find_map(ast::NamedFieldDef::cast)?; + let field = ident.parent().ancestors().find_map(ast::RecordFieldDef::cast)?; if field.name()?.syntax().text_range() != ident.text_range() && field.visibility().is_some() { return None; diff --git a/crates/ra_assists/src/fill_match_arms.rs b/crates/ra_assists/src/fill_match_arms.rs index ce715a449..cc3879562 100644 --- a/crates/ra_assists/src/fill_match_arms.rs +++ b/crates/ra_assists/src/fill_match_arms.rs @@ -78,7 +78,7 @@ fn build_pat(var: ast::EnumVariant) -> Option { let pats = field_list .fields() .map(|f| AstBuilder::::from_name(&f.name().unwrap()).into()); - AstBuilder::::from_pieces(path, pats).into() + AstBuilder::::from_pieces(path, pats).into() } ast::StructKind::Unit => AstBuilder::::from_path(path).into(), }; -- cgit v1.2.3