diff options
Diffstat (limited to 'crates/ra_syntax/src/parsing/grammar.rs')
-rw-r--r-- | crates/ra_syntax/src/parsing/grammar.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/ra_syntax/src/parsing/grammar.rs b/crates/ra_syntax/src/parsing/grammar.rs index 7ca9c223c..800d5a4a2 100644 --- a/crates/ra_syntax/src/parsing/grammar.rs +++ b/crates/ra_syntax/src/parsing/grammar.rs | |||
@@ -37,7 +37,6 @@ mod type_params; | |||
37 | mod types; | 37 | mod types; |
38 | 38 | ||
39 | use crate::{ | 39 | use crate::{ |
40 | SyntaxNode, | ||
41 | SyntaxKind::{self, *}, | 40 | SyntaxKind::{self, *}, |
42 | parsing::{ | 41 | parsing::{ |
43 | token_set::TokenSet, | 42 | token_set::TokenSet, |
@@ -52,8 +51,12 @@ pub(super) fn root(p: &mut Parser) { | |||
52 | m.complete(p, SOURCE_FILE); | 51 | m.complete(p, SOURCE_FILE); |
53 | } | 52 | } |
54 | 53 | ||
55 | pub(super) fn reparser(node: &SyntaxNode) -> Option<fn(&mut Parser)> { | 54 | pub(super) fn reparser( |
56 | let res = match node.kind() { | 55 | node: SyntaxKind, |
56 | first_child: Option<SyntaxKind>, | ||
57 | parent: Option<SyntaxKind>, | ||
58 | ) -> Option<fn(&mut Parser)> { | ||
59 | let res = match node { | ||
57 | BLOCK => expressions::block, | 60 | BLOCK => expressions::block, |
58 | NAMED_FIELD_DEF_LIST => items::named_field_def_list, | 61 | NAMED_FIELD_DEF_LIST => items::named_field_def_list, |
59 | NAMED_FIELD_LIST => items::named_field_list, | 62 | NAMED_FIELD_LIST => items::named_field_list, |
@@ -61,16 +64,13 @@ pub(super) fn reparser(node: &SyntaxNode) -> Option<fn(&mut Parser)> { | |||
61 | MATCH_ARM_LIST => items::match_arm_list, | 64 | MATCH_ARM_LIST => items::match_arm_list, |
62 | USE_TREE_LIST => items::use_tree_list, | 65 | USE_TREE_LIST => items::use_tree_list, |
63 | EXTERN_ITEM_LIST => items::extern_item_list, | 66 | EXTERN_ITEM_LIST => items::extern_item_list, |
64 | TOKEN_TREE if node.first_child().unwrap().kind() == L_CURLY => items::token_tree, | 67 | TOKEN_TREE if first_child? == L_CURLY => items::token_tree, |
65 | ITEM_LIST => { | 68 | ITEM_LIST => match parent? { |
66 | let parent = node.parent().unwrap(); | 69 | IMPL_BLOCK => items::impl_item_list, |
67 | match parent.kind() { | 70 | TRAIT_DEF => items::trait_item_list, |
68 | IMPL_BLOCK => items::impl_item_list, | 71 | MODULE => items::mod_item_list, |
69 | TRAIT_DEF => items::trait_item_list, | 72 | _ => return None, |
70 | MODULE => items::mod_item_list, | 73 | }, |
71 | _ => return None, | ||
72 | } | ||
73 | } | ||
74 | _ => return None, | 74 | _ => return None, |
75 | }; | 75 | }; |
76 | Some(res) | 76 | Some(res) |