diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-15 13:45:58 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-15 13:45:58 +0100 |
commit | ec7d2f64ade9ffa35a64e82ac53e65ad5cbe9efd (patch) | |
tree | b8693ce808a9ca2e7eaae5013644a1082fc7bb17 /crates/ra_assists/src/ast_editor.rs | |
parent | 64ab5ab10d32e7e8ec085af818d3d94211aea39b (diff) | |
parent | 993abedd77cf23ce2281b6c8e60cab49ab4fa97e (diff) |
Merge #1278
1278: Apply T! macro where posible r=matklad a=pasa
apply T! macro implemented in #1248
Co-authored-by: Sergey Parilin <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/ast_editor.rs')
-rw-r--r-- | crates/ra_assists/src/ast_editor.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs index aa7aeaabb..9afcac01a 100644 --- a/crates/ra_assists/src/ast_editor.rs +++ b/crates/ra_assists/src/ast_editor.rs | |||
@@ -2,7 +2,7 @@ use std::{iter, ops::RangeInclusive}; | |||
2 | 2 | ||
3 | use arrayvec::ArrayVec; | 3 | use arrayvec::ArrayVec; |
4 | use ra_text_edit::TextEditBuilder; | 4 | use ra_text_edit::TextEditBuilder; |
5 | use ra_syntax::{AstNode, TreeArc, ast, SyntaxKind::*, SyntaxElement, SourceFile, InsertPosition, Direction}; | 5 | use ra_syntax::{AstNode, TreeArc, ast, SyntaxKind::*, SyntaxElement, SourceFile, InsertPosition, Direction, T}; |
6 | use ra_fmt::leading_indent; | 6 | use ra_fmt::leading_indent; |
7 | use hir::Name; | 7 | use hir::Name; |
8 | 8 | ||
@@ -49,7 +49,7 @@ impl<N: AstNode> AstEditor<N> { | |||
49 | 49 | ||
50 | fn do_make_multiline(&mut self) { | 50 | fn do_make_multiline(&mut self) { |
51 | let l_curly = | 51 | let l_curly = |
52 | match self.ast().syntax().children_with_tokens().find(|it| it.kind() == L_CURLY) { | 52 | match self.ast().syntax().children_with_tokens().find(|it| it.kind() == T!['{']) { |
53 | Some(it) => it, | 53 | Some(it) => it, |
54 | None => return, | 54 | None => return, |
55 | }; | 55 | }; |
@@ -124,7 +124,7 @@ impl AstEditor<ast::NamedFieldList> { | |||
124 | if let Some(comma) = $anchor | 124 | if let Some(comma) = $anchor |
125 | .syntax() | 125 | .syntax() |
126 | .siblings_with_tokens(Direction::Next) | 126 | .siblings_with_tokens(Direction::Next) |
127 | .find(|it| it.kind() == COMMA) | 127 | .find(|it| it.kind() == T![,]) |
128 | { | 128 | { |
129 | InsertPosition::After(comma) | 129 | InsertPosition::After(comma) |
130 | } else { | 130 | } else { |
@@ -154,7 +154,7 @@ impl AstEditor<ast::NamedFieldList> { | |||
154 | } | 154 | } |
155 | 155 | ||
156 | fn l_curly(&self) -> Option<SyntaxElement> { | 156 | fn l_curly(&self) -> Option<SyntaxElement> { |
157 | self.ast().syntax().children_with_tokens().find(|it| it.kind() == L_CURLY) | 157 | self.ast().syntax().children_with_tokens().find(|it| it.kind() == T!['{']) |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
@@ -188,7 +188,7 @@ impl AstEditor<ast::ItemList> { | |||
188 | } | 188 | } |
189 | 189 | ||
190 | fn l_curly(&self) -> Option<SyntaxElement> { | 190 | fn l_curly(&self) -> Option<SyntaxElement> { |
191 | self.ast().syntax().children_with_tokens().find(|it| it.kind() == L_CURLY) | 191 | self.ast().syntax().children_with_tokens().find(|it| it.kind() == T!['{']) |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
@@ -290,7 +290,7 @@ fn ast_node_from_file_text<N: AstNode>(text: &str) -> TreeArc<N> { | |||
290 | 290 | ||
291 | mod tokens { | 291 | mod tokens { |
292 | use once_cell::sync::Lazy; | 292 | use once_cell::sync::Lazy; |
293 | use ra_syntax::{AstNode, SourceFile, TreeArc, SyntaxToken, SyntaxKind::*}; | 293 | use ra_syntax::{AstNode, SourceFile, TreeArc, SyntaxToken, SyntaxKind::*, T}; |
294 | 294 | ||
295 | static SOURCE_FILE: Lazy<TreeArc<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;")); | 295 | static SOURCE_FILE: Lazy<TreeArc<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;")); |
296 | 296 | ||
@@ -299,7 +299,7 @@ mod tokens { | |||
299 | .syntax() | 299 | .syntax() |
300 | .descendants_with_tokens() | 300 | .descendants_with_tokens() |
301 | .filter_map(|it| it.as_token()) | 301 | .filter_map(|it| it.as_token()) |
302 | .find(|it| it.kind() == COMMA) | 302 | .find(|it| it.kind() == T![,]) |
303 | .unwrap() | 303 | .unwrap() |
304 | } | 304 | } |
305 | 305 | ||