diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-23 15:01:06 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-23 15:01:06 +0100 |
commit | a832a2f7dd22c93bc69a7be5d24799bb042b8129 (patch) | |
tree | 15f55b3eab48c3d0bbb1975fbd4db7cbb56d3e3e /crates/ra_assists/src | |
parent | c12dce0073c1766f7d2b10a69f8526a8093e70dc (diff) | |
parent | 5b18a4eef9e69260ce2f105b33553c929cb7d827 (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')
-rw-r--r-- | crates/ra_assists/src/ast_editor.rs | 22 | ||||
-rw-r--r-- | crates/ra_assists/src/change_visibility.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/fill_match_arms.rs | 2 |
3 files changed, 13 insertions, 13 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 | ||
96 | impl AstEditor<ast::NamedFieldList> { | 96 | impl 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 | ||
248 | impl AstBuilder<ast::NamedField> { | 248 | impl 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 | ||
339 | impl AstBuilder<ast::StructPat> { | 339 | impl 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 | } |
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<impl HirDatabase>) -> Option<Assist> { | |||
38 | (vis_offset(&parent), keyword.text_range()) | 38 | (vis_offset(&parent), keyword.text_range()) |
39 | } else { | 39 | } else { |
40 | let ident = ctx.token_at_offset().find(|leaf| leaf.kind() == IDENT)?; | 40 | let ident = ctx.token_at_offset().find(|leaf| leaf.kind() == IDENT)?; |
41 | let field = ident.parent().ancestors().find_map(ast::NamedFieldDef::cast)?; | 41 | let field = ident.parent().ancestors().find_map(ast::RecordFieldDef::cast)?; |
42 | if field.name()?.syntax().text_range() != ident.text_range() && field.visibility().is_some() | 42 | if field.name()?.syntax().text_range() != ident.text_range() && field.visibility().is_some() |
43 | { | 43 | { |
44 | return None; | 44 | 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<ast::Pat> { | |||
78 | let pats = field_list | 78 | let pats = field_list |
79 | .fields() | 79 | .fields() |
80 | .map(|f| AstBuilder::<ast::BindPat>::from_name(&f.name().unwrap()).into()); | 80 | .map(|f| AstBuilder::<ast::BindPat>::from_name(&f.name().unwrap()).into()); |
81 | AstBuilder::<ast::StructPat>::from_pieces(path, pats).into() | 81 | AstBuilder::<ast::RecordPat>::from_pieces(path, pats).into() |
82 | } | 82 | } |
83 | ast::StructKind::Unit => AstBuilder::<ast::PathPat>::from_path(path).into(), | 83 | ast::StructKind::Unit => AstBuilder::<ast::PathPat>::from_path(path).into(), |
84 | }; | 84 | }; |