aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorJosh Robson Chase <[email protected]>2019-01-23 18:14:34 +0000
committerJosh Robson Chase <[email protected]>2019-01-23 18:19:49 +0000
commit3b70acad0106e4ffe5ee68d565c9130b5b271e22 (patch)
tree72b32afb919c5317219c0891ced8c9725d622bbc /crates/ra_syntax/src
parent1cd6d6539a9d85bc44db364bb9165e6d9253790d (diff)
Use IDENT for both raw and normal idents
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs4
-rw-r--r--crates/ra_syntax/src/grammar.ron5
-rw-r--r--crates/ra_syntax/src/grammar.rs4
-rw-r--r--crates/ra_syntax/src/grammar/expressions.rs8
-rw-r--r--crates/ra_syntax/src/grammar/expressions/atom.rs1
-rw-r--r--crates/ra_syntax/src/grammar/items.rs10
-rw-r--r--crates/ra_syntax/src/grammar/items/nominal.rs4
-rw-r--r--crates/ra_syntax/src/grammar/items/traits.rs2
-rw-r--r--crates/ra_syntax/src/grammar/params.rs6
-rw-r--r--crates/ra_syntax/src/grammar/paths.rs6
-rw-r--r--crates/ra_syntax/src/grammar/patterns.rs6
-rw-r--r--crates/ra_syntax/src/grammar/type_args.rs2
-rw-r--r--crates/ra_syntax/src/grammar/type_params.rs4
-rw-r--r--crates/ra_syntax/src/lexer.rs16
-rw-r--r--crates/ra_syntax/src/parser_api.rs8
-rw-r--r--crates/ra_syntax/src/reparsing.rs4
-rw-r--r--crates/ra_syntax/src/syntax_kinds/generated.rs10
-rw-r--r--crates/ra_syntax/src/syntax_kinds/generated.rs.tera9
-rw-r--r--crates/ra_syntax/src/yellow.rs2
19 files changed, 36 insertions, 75 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 4d8412d46..bcbd4c60c 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -142,7 +142,7 @@ impl Attr {
142 pub fn as_atom(&self) -> Option<SmolStr> { 142 pub fn as_atom(&self) -> Option<SmolStr> {
143 let tt = self.value()?; 143 let tt = self.value()?;
144 let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?; 144 let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?;
145 if attr.kind().is_ident() { 145 if attr.kind() == IDENT {
146 Some(attr.leaf_text().unwrap().clone()) 146 Some(attr.leaf_text().unwrap().clone())
147 } else { 147 } else {
148 None 148 None
@@ -153,7 +153,7 @@ impl Attr {
153 let tt = self.value()?; 153 let tt = self.value()?;
154 let (_bra, attr, args, _ket) = tt.syntax().children().collect_tuple()?; 154 let (_bra, attr, args, _ket) = tt.syntax().children().collect_tuple()?;
155 let args = TokenTree::cast(args)?; 155 let args = TokenTree::cast(args)?;
156 if attr.kind().is_ident() { 156 if attr.kind() == IDENT {
157 Some((attr.leaf_text().unwrap().clone(), args)) 157 Some((attr.leaf_text().unwrap().clone(), args))
158 } else { 158 } else {
159 None 159 None
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 64beb8252..0385183fd 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -102,7 +102,6 @@ Grammar(
102 tokens: [ 102 tokens: [
103 "ERROR", 103 "ERROR",
104 "IDENT", 104 "IDENT",
105 "RAW_IDENT",
106 "UNDERSCORE", 105 "UNDERSCORE",
107 "WHITESPACE", 106 "WHITESPACE",
108 "INT_NUMBER", 107 "INT_NUMBER",
@@ -117,10 +116,6 @@ Grammar(
117 "COMMENT", 116 "COMMENT",
118 "SHEBANG", 117 "SHEBANG",
119 ], 118 ],
120 ident_tokens: [
121 "IDENT",
122 "RAW_IDENT",
123 ],
124 nodes: [ 119 nodes: [
125 "SOURCE_FILE", 120 "SOURCE_FILE",
126 121
diff --git a/crates/ra_syntax/src/grammar.rs b/crates/ra_syntax/src/grammar.rs
index 531d0458f..060c0ccdf 100644
--- a/crates/ra_syntax/src/grammar.rs
+++ b/crates/ra_syntax/src/grammar.rs
@@ -140,7 +140,7 @@ fn opt_fn_ret_type(p: &mut Parser) -> bool {
140} 140}
141 141
142fn name_r(p: &mut Parser, recovery: TokenSet) { 142fn name_r(p: &mut Parser, recovery: TokenSet) {
143 if p.current().is_ident() { 143 if p.at(IDENT) {
144 let m = p.start(); 144 let m = p.start();
145 p.bump(); 145 p.bump();
146 m.complete(p, NAME); 146 m.complete(p, NAME);
@@ -154,7 +154,7 @@ fn name(p: &mut Parser) {
154} 154}
155 155
156fn name_ref(p: &mut Parser) { 156fn name_ref(p: &mut Parser) {
157 if p.current().is_ident() { 157 if p.at(IDENT) {
158 let m = p.start(); 158 let m = p.start();
159 p.bump(); 159 p.bump();
160 m.complete(p, NAME_REF); 160 m.complete(p, NAME_REF);
diff --git a/crates/ra_syntax/src/grammar/expressions.rs b/crates/ra_syntax/src/grammar/expressions.rs
index 107b7cda4..2236555e0 100644
--- a/crates/ra_syntax/src/grammar/expressions.rs
+++ b/crates/ra_syntax/src/grammar/expressions.rs
@@ -281,7 +281,7 @@ fn postfix_expr(
281 // } 281 // }
282 L_PAREN if allow_calls => call_expr(p, lhs), 282 L_PAREN if allow_calls => call_expr(p, lhs),
283 L_BRACK if allow_calls => index_expr(p, lhs), 283 L_BRACK if allow_calls => index_expr(p, lhs),
284 DOT if p.nth(1).is_ident() && (p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON) => { 284 DOT if p.nth(1) == IDENT && (p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON) => {
285 method_call_expr(p, lhs) 285 method_call_expr(p, lhs)
286 } 286 }
287 DOT => field_expr(p, lhs), 287 DOT => field_expr(p, lhs),
@@ -332,7 +332,7 @@ fn index_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
332// y.bar::<T>(1, 2,); 332// y.bar::<T>(1, 2,);
333// } 333// }
334fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { 334fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
335 assert!(p.at(DOT) && p.nth(1).is_ident() && (p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON)); 335 assert!(p.at(DOT) && p.nth(1) == IDENT && (p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON));
336 let m = lhs.precede(p); 336 let m = lhs.precede(p);
337 p.bump(); 337 p.bump();
338 name_ref(p); 338 name_ref(p);
@@ -352,7 +352,7 @@ fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
352 assert!(p.at(DOT)); 352 assert!(p.at(DOT));
353 let m = lhs.precede(p); 353 let m = lhs.precede(p);
354 p.bump(); 354 p.bump();
355 if p.current().is_ident() { 355 if p.at(IDENT) {
356 name_ref(p) 356 name_ref(p)
357 } else if p.at(INT_NUMBER) { 357 } else if p.at(INT_NUMBER) {
358 p.bump() 358 p.bump()
@@ -443,7 +443,7 @@ pub(crate) fn named_field_list(p: &mut Parser) {
443 p.bump(); 443 p.bump();
444 while !p.at(EOF) && !p.at(R_CURLY) { 444 while !p.at(EOF) && !p.at(R_CURLY) {
445 match p.current() { 445 match p.current() {
446 IDENT | RAW_IDENT => { 446 IDENT => {
447 let m = p.start(); 447 let m = p.start();
448 name_ref(p); 448 name_ref(p);
449 if p.eat(COLON) { 449 if p.eat(COLON) {
diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs
index 3fbe22856..167a76551 100644
--- a/crates/ra_syntax/src/grammar/expressions/atom.rs
+++ b/crates/ra_syntax/src/grammar/expressions/atom.rs
@@ -48,7 +48,6 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = LITERAL_FIRST.union(token_set![
48 UNSAFE_KW, 48 UNSAFE_KW,
49 RETURN_KW, 49 RETURN_KW,
50 IDENT, 50 IDENT,
51 RAW_IDENT,
52 SELF_KW, 51 SELF_KW,
53 SUPER_KW, 52 SUPER_KW,
54 CRATE_KW, 53 CRATE_KW,
diff --git a/crates/ra_syntax/src/grammar/items.rs b/crates/ra_syntax/src/grammar/items.rs
index c49798444..265e84570 100644
--- a/crates/ra_syntax/src/grammar/items.rs
+++ b/crates/ra_syntax/src/grammar/items.rs
@@ -99,11 +99,11 @@ pub(super) fn maybe_item(p: &mut Parser, flavor: ItemFlavor) -> MaybeItem {
99 has_mods = true; 99 has_mods = true;
100 abi(p); 100 abi(p);
101 } 101 }
102 if p.current().is_ident() && p.at_contextual_kw("auto") && p.nth(1) == TRAIT_KW { 102 if p.at(IDENT) && p.at_contextual_kw("auto") && p.nth(1) == TRAIT_KW {
103 p.bump_remap(AUTO_KW); 103 p.bump_remap(AUTO_KW);
104 has_mods = true; 104 has_mods = true;
105 } 105 }
106 if p.current().is_ident() && p.at_contextual_kw("default") && p.nth(1) == IMPL_KW { 106 if p.at(IDENT) && p.at_contextual_kw("default") && p.nth(1) == IMPL_KW {
107 p.bump_remap(DEFAULT_KW); 107 p.bump_remap(DEFAULT_KW);
108 has_mods = true; 108 has_mods = true;
109 } 109 }
@@ -202,7 +202,7 @@ fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> {
202 } 202 }
203 STRUCT_DEF 203 STRUCT_DEF
204 } 204 }
205 IDENT | RAW_IDENT if p.at_contextual_kw("union") && p.nth(1).is_ident() => { 205 IDENT if p.at_contextual_kw("union") && p.nth(1) == IDENT => {
206 // test union_items 206 // test union_items
207 // union Foo {} 207 // union Foo {}
208 // union Foo { 208 // union Foo {
@@ -220,7 +220,7 @@ fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> {
220 use_item::use_item(p); 220 use_item::use_item(p);
221 USE_ITEM 221 USE_ITEM
222 } 222 }
223 CONST_KW if (la.is_ident() || la == MUT_KW) => { 223 CONST_KW if (la == IDENT || la == MUT_KW) => {
224 consts::const_def(p); 224 consts::const_def(p);
225 CONST_DEF 225 CONST_DEF
226 } 226 }
@@ -351,7 +351,7 @@ fn macro_call(p: &mut Parser) -> BlockLike {
351 351
352pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike { 352pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
353 p.expect(EXCL); 353 p.expect(EXCL);
354 p.eat_one(&[IDENT, RAW_IDENT]); 354 p.eat(IDENT);
355 match p.current() { 355 match p.current() {
356 L_CURLY => { 356 L_CURLY => {
357 token_tree(p); 357 token_tree(p);
diff --git a/crates/ra_syntax/src/grammar/items/nominal.rs b/crates/ra_syntax/src/grammar/items/nominal.rs
index 897306883..0784fb7b1 100644
--- a/crates/ra_syntax/src/grammar/items/nominal.rs
+++ b/crates/ra_syntax/src/grammar/items/nominal.rs
@@ -70,7 +70,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
70 } 70 }
71 let var = p.start(); 71 let var = p.start();
72 attributes::outer_attributes(p); 72 attributes::outer_attributes(p);
73 if p.current().is_ident() { 73 if p.at(IDENT) {
74 name(p); 74 name(p);
75 match p.current() { 75 match p.current() {
76 L_CURLY => named_field_def_list(p), 76 L_CURLY => named_field_def_list(p),
@@ -120,7 +120,7 @@ pub(crate) fn named_field_def_list(p: &mut Parser) {
120 // } 120 // }
121 attributes::outer_attributes(p); 121 attributes::outer_attributes(p);
122 opt_visibility(p); 122 opt_visibility(p);
123 if p.current().is_ident() { 123 if p.at(IDENT) {
124 name(p); 124 name(p);
125 p.expect(COLON); 125 p.expect(COLON);
126 types::type_(p); 126 types::type_(p);
diff --git a/crates/ra_syntax/src/grammar/items/traits.rs b/crates/ra_syntax/src/grammar/items/traits.rs
index a78bbba2b..0a0621753 100644
--- a/crates/ra_syntax/src/grammar/items/traits.rs
+++ b/crates/ra_syntax/src/grammar/items/traits.rs
@@ -112,7 +112,7 @@ fn choose_type_params_over_qpath(p: &Parser) -> bool {
112 if p.nth(1) == POUND || p.nth(1) == R_ANGLE { 112 if p.nth(1) == POUND || p.nth(1) == R_ANGLE {
113 return true; 113 return true;
114 } 114 }
115 (p.nth(1) == LIFETIME || p.nth(1).is_ident()) 115 (p.nth(1) == LIFETIME || p.nth(1) == IDENT)
116 && (p.nth(2) == R_ANGLE || p.nth(2) == COMMA || p.nth(2) == COLON || p.nth(2) == EQ) 116 && (p.nth(2) == R_ANGLE || p.nth(2) == COMMA || p.nth(2) == COLON || p.nth(2) == EQ)
117} 117}
118 118
diff --git a/crates/ra_syntax/src/grammar/params.rs b/crates/ra_syntax/src/grammar/params.rs
index ada07c17e..13158429a 100644
--- a/crates/ra_syntax/src/grammar/params.rs
+++ b/crates/ra_syntax/src/grammar/params.rs
@@ -84,9 +84,9 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) {
84 // trait Foo { 84 // trait Foo {
85 // fn bar(_: u64); 85 // fn bar(_: u64);
86 // } 86 // }
87 if (la0.is_ident() || la0 == UNDERSCORE) && la1 == COLON 87 if (la0 == IDENT || la0 == UNDERSCORE) && la1 == COLON
88 || la0 == AMP && la1.is_ident() && la2 == COLON 88 || la0 == AMP && la1 == IDENT && la2 == COLON
89 || la0 == AMP && la1 == MUT_KW && la2.is_ident() && la3 == COLON 89 || la0 == AMP && la1 == MUT_KW && la2 == IDENT && la3 == COLON
90 { 90 {
91 patterns::pattern(p); 91 patterns::pattern(p);
92 types::ascription(p); 92 types::ascription(p);
diff --git a/crates/ra_syntax/src/grammar/paths.rs b/crates/ra_syntax/src/grammar/paths.rs
index 0e1c1d334..33a11886c 100644
--- a/crates/ra_syntax/src/grammar/paths.rs
+++ b/crates/ra_syntax/src/grammar/paths.rs
@@ -1,11 +1,11 @@
1use super::*; 1use super::*;
2 2
3pub(super) const PATH_FIRST: TokenSet = 3pub(super) const PATH_FIRST: TokenSet =
4 token_set![IDENT, RAW_IDENT, SELF_KW, SUPER_KW, CRATE_KW, COLONCOLON, L_ANGLE]; 4 token_set![IDENT, SELF_KW, SUPER_KW, CRATE_KW, COLONCOLON, L_ANGLE];
5 5
6pub(super) fn is_path_start(p: &Parser) -> bool { 6pub(super) fn is_path_start(p: &Parser) -> bool {
7 match p.current() { 7 match p.current() {
8 IDENT | RAW_IDENT | SELF_KW | SUPER_KW | CRATE_KW | COLONCOLON => true, 8 IDENT | SELF_KW | SUPER_KW | CRATE_KW | COLONCOLON => true,
9 _ => false, 9 _ => false,
10 } 10 }
11} 11}
@@ -70,7 +70,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
70 p.eat(COLONCOLON); 70 p.eat(COLONCOLON);
71 } 71 }
72 match p.current() { 72 match p.current() {
73 IDENT | RAW_IDENT => { 73 IDENT => {
74 name_ref(p); 74 name_ref(p);
75 opt_path_type_args(p, mode); 75 opt_path_type_args(p, mode);
76 } 76 }
diff --git a/crates/ra_syntax/src/grammar/patterns.rs b/crates/ra_syntax/src/grammar/patterns.rs
index 925eabe1b..1ac5efdf6 100644
--- a/crates/ra_syntax/src/grammar/patterns.rs
+++ b/crates/ra_syntax/src/grammar/patterns.rs
@@ -37,7 +37,7 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
37 let la1 = p.nth(1); 37 let la1 = p.nth(1);
38 if la0 == REF_KW 38 if la0 == REF_KW
39 || la0 == MUT_KW 39 || la0 == MUT_KW
40 || (la0.is_ident() && !(la1 == COLONCOLON || la1 == L_PAREN || la1 == L_CURLY)) 40 || (la0 == IDENT && !(la1 == COLONCOLON || la1 == L_PAREN || la1 == L_CURLY))
41 { 41 {
42 return Some(bind_pat(p, true)); 42 return Some(bind_pat(p, true));
43 } 43 }
@@ -128,7 +128,7 @@ fn field_pat_list(p: &mut Parser) {
128 while !p.at(EOF) && !p.at(R_CURLY) { 128 while !p.at(EOF) && !p.at(R_CURLY) {
129 match p.current() { 129 match p.current() {
130 DOTDOT => p.bump(), 130 DOTDOT => p.bump(),
131 IDENT | RAW_IDENT if p.nth(1) == COLON => field_pat(p), 131 IDENT if p.nth(1) == COLON => field_pat(p),
132 L_CURLY => error_block(p, "expected ident"), 132 L_CURLY => error_block(p, "expected ident"),
133 _ => { 133 _ => {
134 bind_pat(p, false); 134 bind_pat(p, false);
@@ -143,7 +143,7 @@ fn field_pat_list(p: &mut Parser) {
143} 143}
144 144
145fn field_pat(p: &mut Parser) { 145fn field_pat(p: &mut Parser) {
146 assert!(p.current().is_ident()); 146 assert!(p.at(IDENT));
147 assert!(p.nth(1) == COLON); 147 assert!(p.nth(1) == COLON);
148 148
149 let m = p.start(); 149 let m = p.start();
diff --git a/crates/ra_syntax/src/grammar/type_args.rs b/crates/ra_syntax/src/grammar/type_args.rs
index 469595d71..f889419c5 100644
--- a/crates/ra_syntax/src/grammar/type_args.rs
+++ b/crates/ra_syntax/src/grammar/type_args.rs
@@ -34,7 +34,7 @@ fn type_arg(p: &mut Parser) {
34 p.bump(); 34 p.bump();
35 m.complete(p, LIFETIME_ARG); 35 m.complete(p, LIFETIME_ARG);
36 } 36 }
37 IDENT | RAW_IDENT if p.nth(1) == EQ => { 37 IDENT if p.nth(1) == EQ => {
38 name_ref(p); 38 name_ref(p);
39 p.bump(); 39 p.bump();
40 types::type_(p); 40 types::type_(p);
diff --git a/crates/ra_syntax/src/grammar/type_params.rs b/crates/ra_syntax/src/grammar/type_params.rs
index 3cebd0675..1ec813b3e 100644
--- a/crates/ra_syntax/src/grammar/type_params.rs
+++ b/crates/ra_syntax/src/grammar/type_params.rs
@@ -15,7 +15,7 @@ fn type_param_list(p: &mut Parser) {
15 while !p.at(EOF) && !p.at(R_ANGLE) { 15 while !p.at(EOF) && !p.at(R_ANGLE) {
16 match p.current() { 16 match p.current() {
17 LIFETIME => lifetime_param(p), 17 LIFETIME => lifetime_param(p),
18 IDENT | RAW_IDENT => type_param(p), 18 IDENT => type_param(p),
19 _ => p.err_and_bump("expected type parameter"), 19 _ => p.err_and_bump("expected type parameter"),
20 } 20 }
21 if !p.at(R_ANGLE) && !p.expect(COMMA) { 21 if !p.at(R_ANGLE) && !p.expect(COMMA) {
@@ -37,7 +37,7 @@ fn lifetime_param(p: &mut Parser) {
37} 37}
38 38
39fn type_param(p: &mut Parser) { 39fn type_param(p: &mut Parser) {
40 assert!(p.current().is_ident()); 40 assert!(p.at(IDENT));
41 let m = p.start(); 41 let m = p.start();
42 name(p); 42 name(p);
43 if p.at(COLON) { 43 if p.at(COLON) {
diff --git a/crates/ra_syntax/src/lexer.rs b/crates/ra_syntax/src/lexer.rs
index fab184a2d..0c3847120 100644
--- a/crates/ra_syntax/src/lexer.rs
+++ b/crates/ra_syntax/src/lexer.rs
@@ -190,24 +190,18 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
190} 190}
191 191
192fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { 192fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind {
193 let is_raw = match (c, ptr.current()) { 193 match (c, ptr.current()) {
194 ('r', Some('#')) => { 194 ('r', Some('#')) => {
195 ptr.bump(); 195 ptr.bump();
196 true
197 } 196 }
198 ('_', Some(c)) if !is_ident_continue(c) => return UNDERSCORE, 197 ('_', Some(c)) if !is_ident_continue(c) => return UNDERSCORE,
199 _ => false, 198 _ => {}
200 }; 199 }
201
202 ptr.bump_while(is_ident_continue); 200 ptr.bump_while(is_ident_continue);
203 201 if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) {
204 if is_raw {
205 RAW_IDENT
206 } else if let Some(kind) = SyntaxKind::from_keyword(ptr.current_token_text()) {
207 return kind; 202 return kind;
208 } else {
209 IDENT
210 } 203 }
204 IDENT
211} 205}
212 206
213fn scan_literal_suffix(ptr: &mut Ptr) { 207fn scan_literal_suffix(ptr: &mut Ptr) {
diff --git a/crates/ra_syntax/src/parser_api.rs b/crates/ra_syntax/src/parser_api.rs
index d795cbaf1..3148371c5 100644
--- a/crates/ra_syntax/src/parser_api.rs
+++ b/crates/ra_syntax/src/parser_api.rs
@@ -100,14 +100,6 @@ impl<'t> Parser<'t> {
100 true 100 true
101 } 101 }
102 102
103 /// Consume the next token matching one of the `kinds`
104 pub(crate) fn eat_one<'k, K>(&mut self, kinds: K) -> bool
105 where
106 K: IntoIterator<Item = &'k SyntaxKind> + 'k,
107 {
108 kinds.into_iter().map(|k| self.eat(*k)).any(|eaten| eaten)
109 }
110
111 /// Consume the next token if it is `kind` or emit an error 103 /// Consume the next token if it is `kind` or emit an error
112 /// otherwise. 104 /// otherwise.
113 pub(crate) fn expect(&mut self, kind: SyntaxKind) -> bool { 105 pub(crate) fn expect(&mut self, kind: SyntaxKind) -> bool {
diff --git a/crates/ra_syntax/src/reparsing.rs b/crates/ra_syntax/src/reparsing.rs
index b38985bc8..2f1de6b02 100644
--- a/crates/ra_syntax/src/reparsing.rs
+++ b/crates/ra_syntax/src/reparsing.rs
@@ -25,7 +25,7 @@ fn reparse_leaf<'node>(
25) -> Option<(&'node SyntaxNode, GreenNode, Vec<SyntaxError>)> { 25) -> Option<(&'node SyntaxNode, GreenNode, Vec<SyntaxError>)> {
26 let node = algo::find_covering_node(node, edit.delete); 26 let node = algo::find_covering_node(node, edit.delete);
27 match node.kind() { 27 match node.kind() {
28 WHITESPACE | COMMENT | IDENT | RAW_IDENT | STRING | RAW_STRING => { 28 WHITESPACE | COMMENT | IDENT | STRING | RAW_STRING => {
29 let text = get_text_after_edit(node, &edit); 29 let text = get_text_after_edit(node, &edit);
30 let tokens = tokenize(&text); 30 let tokens = tokenize(&text);
31 let token = match tokens[..] { 31 let token = match tokens[..] {
@@ -33,7 +33,7 @@ fn reparse_leaf<'node>(
33 _ => return None, 33 _ => return None,
34 }; 34 };
35 35
36 if token.kind.is_ident() && is_contextual_kw(&text) { 36 if token.kind == IDENT && is_contextual_kw(&text) {
37 return None; 37 return None;
38 } 38 }
39 39
diff --git a/crates/ra_syntax/src/syntax_kinds/generated.rs b/crates/ra_syntax/src/syntax_kinds/generated.rs
index aa1ab3326..06faf7557 100644
--- a/crates/ra_syntax/src/syntax_kinds/generated.rs
+++ b/crates/ra_syntax/src/syntax_kinds/generated.rs
@@ -105,7 +105,6 @@ pub enum SyntaxKind {
105 UNION_KW, 105 UNION_KW,
106 ERROR, 106 ERROR,
107 IDENT, 107 IDENT,
108 RAW_IDENT,
109 UNDERSCORE, 108 UNDERSCORE,
110 WHITESPACE, 109 WHITESPACE,
111 INT_NUMBER, 110 INT_NUMBER,
@@ -369,7 +368,6 @@ impl SyntaxKind {
369 UNION_KW => &SyntaxInfo { name: "UNION_KW" }, 368 UNION_KW => &SyntaxInfo { name: "UNION_KW" },
370 ERROR => &SyntaxInfo { name: "ERROR" }, 369 ERROR => &SyntaxInfo { name: "ERROR" },
371 IDENT => &SyntaxInfo { name: "IDENT" }, 370 IDENT => &SyntaxInfo { name: "IDENT" },
372 RAW_IDENT => &SyntaxInfo { name: "RAW_IDENT" },
373 UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" }, 371 UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" },
374 WHITESPACE => &SyntaxInfo { name: "WHITESPACE" }, 372 WHITESPACE => &SyntaxInfo { name: "WHITESPACE" },
375 INT_NUMBER => &SyntaxInfo { name: "INT_NUMBER" }, 373 INT_NUMBER => &SyntaxInfo { name: "INT_NUMBER" },
@@ -565,12 +563,4 @@ impl SyntaxKind {
565 }; 563 };
566 Some(tok) 564 Some(tok)
567 } 565 }
568
569 pub(crate) fn is_ident(&self) -> bool {
570 match self {
571 | IDENT
572 | RAW_IDENT => true,
573 _ => false,
574 }
575 }
576} 566}
diff --git a/crates/ra_syntax/src/syntax_kinds/generated.rs.tera b/crates/ra_syntax/src/syntax_kinds/generated.rs.tera
index 83787f820..21f9444b1 100644
--- a/crates/ra_syntax/src/syntax_kinds/generated.rs.tera
+++ b/crates/ra_syntax/src/syntax_kinds/generated.rs.tera
@@ -74,13 +74,4 @@ impl SyntaxKind {
74 }; 74 };
75 Some(tok) 75 Some(tok)
76 } 76 }
77
78 pub(crate) fn is_ident(&self) -> bool {
79 match self {
80{%- for kind in ident_tokens %}
81 | {{kind}}
82{%- endfor %} => true,
83 _ => false,
84 }
85 }
86} 77}
diff --git a/crates/ra_syntax/src/yellow.rs b/crates/ra_syntax/src/yellow.rs
index 48f01128b..a7bfb80e2 100644
--- a/crates/ra_syntax/src/yellow.rs
+++ b/crates/ra_syntax/src/yellow.rs
@@ -207,7 +207,7 @@ impl<'a> Iterator for SyntaxNodeChildren<'a> {
207fn has_short_text(kind: SyntaxKind) -> bool { 207fn has_short_text(kind: SyntaxKind) -> bool {
208 use crate::SyntaxKind::*; 208 use crate::SyntaxKind::*;
209 match kind { 209 match kind {
210 IDENT | RAW_IDENT | LIFETIME | INT_NUMBER | FLOAT_NUMBER => true, 210 IDENT | LIFETIME | INT_NUMBER | FLOAT_NUMBER => true,
211 _ => false, 211 _ => false,
212 } 212 }
213} 213}