aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/parsing/reparsing.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-15 13:45:58 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-15 13:45:58 +0100
commitec7d2f64ade9ffa35a64e82ac53e65ad5cbe9efd (patch)
treeb8693ce808a9ca2e7eaae5013644a1082fc7bb17 /crates/ra_syntax/src/parsing/reparsing.rs
parent64ab5ab10d32e7e8ec085af818d3d94211aea39b (diff)
parent993abedd77cf23ce2281b6c8e60cab49ab4fa97e (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_syntax/src/parsing/reparsing.rs')
-rw-r--r--crates/ra_syntax/src/parsing/reparsing.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs
index 434f850d1..6de02a15a 100644
--- a/crates/ra_syntax/src/parsing/reparsing.rs
+++ b/crates/ra_syntax/src/parsing/reparsing.rs
@@ -17,7 +17,8 @@ use crate::{
17 text_token_source::TextTokenSource, 17 text_token_source::TextTokenSource,
18 text_tree_sink::TextTreeSink, 18 text_tree_sink::TextTreeSink,
19 lexer::{tokenize, Token}, 19 lexer::{tokenize, Token},
20 } 20 },
21 T,
21}; 22};
22 23
23pub(crate) fn incremental_reparse( 24pub(crate) fn incremental_reparse(
@@ -122,16 +123,16 @@ fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(&SyntaxN
122 123
123fn is_balanced(tokens: &[Token]) -> bool { 124fn is_balanced(tokens: &[Token]) -> bool {
124 if tokens.is_empty() 125 if tokens.is_empty()
125 || tokens.first().unwrap().kind != L_CURLY 126 || tokens.first().unwrap().kind != T!['{']
126 || tokens.last().unwrap().kind != R_CURLY 127 || tokens.last().unwrap().kind != T!['}']
127 { 128 {
128 return false; 129 return false;
129 } 130 }
130 let mut balance = 0usize; 131 let mut balance = 0usize;
131 for t in &tokens[1..tokens.len() - 1] { 132 for t in &tokens[1..tokens.len() - 1] {
132 match t.kind { 133 match t.kind {
133 L_CURLY => balance += 1, 134 T!['{'] => balance += 1,
134 R_CURLY => { 135 T!['}'] => {
135 balance = match balance.checked_sub(1) { 136 balance = match balance.checked_sub(1) {
136 Some(b) => b, 137 Some(b) => b,
137 None => return false, 138 None => return false,