aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/parsing/reparsing.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/parsing/reparsing.rs')
-rw-r--r--crates/ra_syntax/src/parsing/reparsing.rs26
1 files changed, 1 insertions, 25 deletions
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs
index 994e7e212..0a24dae0e 100644
--- a/crates/ra_syntax/src/parsing/reparsing.rs
+++ b/crates/ra_syntax/src/parsing/reparsing.rs
@@ -81,31 +81,7 @@ fn is_contextual_kw(text: &str) -> bool {
81type ParseFn = fn(&mut Parser); 81type ParseFn = fn(&mut Parser);
82fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(&SyntaxNode, ParseFn)> { 82fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(&SyntaxNode, ParseFn)> {
83 let node = algo::find_covering_node(node, range); 83 let node = algo::find_covering_node(node, range);
84 return node.ancestors().filter_map(|node| reparser(node).map(|r| (node, r))).next(); 84 node.ancestors().find_map(grammar::reparser).map(|r| (node, r))
85
86 fn reparser(node: &SyntaxNode) -> Option<ParseFn> {
87 let res = match node.kind() {
88 BLOCK => grammar::block,
89 NAMED_FIELD_DEF_LIST => grammar::named_field_def_list,
90 NAMED_FIELD_LIST => grammar::named_field_list,
91 ENUM_VARIANT_LIST => grammar::enum_variant_list,
92 MATCH_ARM_LIST => grammar::match_arm_list,
93 USE_TREE_LIST => grammar::use_tree_list,
94 EXTERN_ITEM_LIST => grammar::extern_item_list,
95 TOKEN_TREE if node.first_child().unwrap().kind() == L_CURLY => grammar::token_tree,
96 ITEM_LIST => {
97 let parent = node.parent().unwrap();
98 match parent.kind() {
99 IMPL_BLOCK => grammar::impl_item_list,
100 TRAIT_DEF => grammar::trait_item_list,
101 MODULE => grammar::mod_item_list,
102 _ => return None,
103 }
104 }
105 _ => return None,
106 };
107 Some(res)
108 }
109} 85}
110 86
111fn is_balanced(tokens: &[Token]) -> bool { 87fn is_balanced(tokens: &[Token]) -> bool {