aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/reparsing.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/reparsing.rs')
-rw-r--r--crates/ra_syntax/src/reparsing.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_syntax/src/reparsing.rs b/crates/ra_syntax/src/reparsing.rs
index a0014e016..eae01b1d5 100644
--- a/crates/ra_syntax/src/reparsing.rs
+++ b/crates/ra_syntax/src/reparsing.rs
@@ -98,17 +98,18 @@ fn is_contextual_kw(text: &str) -> bool {
98 } 98 }
99} 99}
100 100
101fn find_reparsable_node<'node>( 101type ParseFn = fn(&mut Parser);
102 node: SyntaxNodeRef<'node>, 102fn find_reparsable_node(
103 node: SyntaxNodeRef<'_>,
103 range: TextRange, 104 range: TextRange,
104) -> Option<(SyntaxNodeRef<'node>, fn(&mut Parser))> { 105) -> Option<(SyntaxNodeRef<'_>, ParseFn)> {
105 let node = algo::find_covering_node(node, range); 106 let node = algo::find_covering_node(node, range);
106 return node 107 return node
107 .ancestors() 108 .ancestors()
108 .filter_map(|node| reparser(node).map(|r| (node, r))) 109 .filter_map(|node| reparser(node).map(|r| (node, r)))
109 .next(); 110 .next();
110 111
111 fn reparser(node: SyntaxNodeRef) -> Option<fn(&mut Parser)> { 112 fn reparser(node: SyntaxNodeRef) -> Option<ParseFn> {
112 let res = match node.kind() { 113 let res = match node.kind() {
113 BLOCK => grammar::block, 114 BLOCK => grammar::block,
114 NAMED_FIELD_DEF_LIST => grammar::named_field_def_list, 115 NAMED_FIELD_DEF_LIST => grammar::named_field_def_list,
@@ -134,7 +135,7 @@ fn find_reparsable_node<'node>(
134} 135}
135 136
136fn is_balanced(tokens: &[Token]) -> bool { 137fn is_balanced(tokens: &[Token]) -> bool {
137 if tokens.len() == 0 138 if tokens.is_empty()
138 || tokens.first().unwrap().kind != L_CURLY 139 || tokens.first().unwrap().kind != L_CURLY
139 || tokens.last().unwrap().kind != R_CURLY 140 || tokens.last().unwrap().kind != R_CURLY
140 { 141 {