aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast.rs6
-rw-r--r--crates/ra_syntax/src/ast/edit.rs6
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs16
-rw-r--r--crates/ra_syntax/src/ast/generated/tokens.rs1296
-rw-r--r--crates/ra_syntax/src/ast/traits.rs5
5 files changed, 23 insertions, 1306 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 1ee60e74c..1437a38c9 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -80,7 +80,7 @@ impl<N: AstNode> Iterator for AstChildren<N> {
80} 80}
81 81
82mod support { 82mod support {
83 use super::{AstChildren, AstNode, AstToken, SyntaxKind, SyntaxNode, SyntaxToken}; 83 use super::{AstChildren, AstNode, SyntaxKind, SyntaxNode, SyntaxToken};
84 84
85 pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> { 85 pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> {
86 parent.children().find_map(N::cast) 86 parent.children().find_map(N::cast)
@@ -90,10 +90,6 @@ mod support {
90 AstChildren::new(parent) 90 AstChildren::new(parent)
91 } 91 }
92 92
93 pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> {
94 parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast)
95 }
96
97 pub(super) fn token2(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> { 93 pub(super) fn token2(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> {
98 parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind) 94 parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind)
99 } 95 }
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 7e14349d2..9e5411ee5 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -189,15 +189,15 @@ impl ast::RecordFieldList {
189impl ast::TypeParam { 189impl ast::TypeParam {
190 #[must_use] 190 #[must_use]
191 pub fn remove_bounds(&self) -> ast::TypeParam { 191 pub fn remove_bounds(&self) -> ast::TypeParam {
192 let colon = match self.colon() { 192 let colon = match self.colon_token() {
193 Some(it) => it, 193 Some(it) => it,
194 None => return self.clone(), 194 None => return self.clone(),
195 }; 195 };
196 let end = match self.type_bound_list() { 196 let end = match self.type_bound_list() {
197 Some(it) => it.syntax().clone().into(), 197 Some(it) => it.syntax().clone().into(),
198 None => colon.syntax().clone().into(), 198 None => colon.clone().into(),
199 }; 199 };
200 self.replace_children(colon.syntax().clone().into()..=end, iter::empty()) 200 self.replace_children(colon.into()..=end, iter::empty())
201 } 201 }
202} 202}
203 203
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index 03d94170d..d91275b53 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -5,7 +5,7 @@ use itertools::Itertools;
5use ra_parser::SyntaxKind; 5use ra_parser::SyntaxKind;
6 6
7use crate::{ 7use crate::{
8 ast::{self, support, AstNode, AstToken, AttrInput, NameOwner, SyntaxNode}, 8 ast::{self, support, AstNode, AttrInput, NameOwner, SyntaxNode},
9 SmolStr, SyntaxElement, SyntaxToken, T, 9 SmolStr, SyntaxElement, SyntaxToken, T,
10}; 10};
11 11
@@ -327,23 +327,23 @@ impl ast::TypeBound {
327 } 327 }
328 } 328 }
329 329
330 pub fn const_question_token(&self) -> Option<ast::Question> { 330 pub fn const_question_token(&self) -> Option<SyntaxToken> {
331 self.syntax() 331 self.syntax()
332 .children_with_tokens() 332 .children_with_tokens()
333 .filter_map(|it| it.into_token()) 333 .filter_map(|it| it.into_token())
334 .take_while(|it| it.kind() != T![const]) 334 .take_while(|it| it.kind() != T![const])
335 .find_map(ast::Question::cast) 335 .find(|it| it.kind() == T![?])
336 } 336 }
337 337
338 pub fn question_token(&self) -> Option<ast::Question> { 338 pub fn question_token(&self) -> Option<SyntaxToken> {
339 if self.const_token().is_some() { 339 if self.const_token().is_some() {
340 self.syntax() 340 self.syntax()
341 .children_with_tokens() 341 .children_with_tokens()
342 .filter_map(|it| it.into_token()) 342 .filter_map(|it| it.into_token())
343 .skip_while(|it| it.kind() != T![const]) 343 .skip_while(|it| it.kind() != T![const])
344 .find_map(ast::Question::cast) 344 .find(|it| it.kind() == T![?])
345 } else { 345 } else {
346 support::token(&self.syntax) 346 support::token2(&self.syntax, T![?])
347 } 347 }
348 } 348 }
349} 349}
@@ -384,12 +384,12 @@ impl ast::MacroCall {
384} 384}
385 385
386impl ast::LifetimeParam { 386impl ast::LifetimeParam {
387 pub fn lifetime_bounds(&self) -> impl Iterator<Item = ast::Lifetime> { 387 pub fn lifetime_bounds(&self) -> impl Iterator<Item = SyntaxToken> {
388 self.syntax() 388 self.syntax()
389 .children_with_tokens() 389 .children_with_tokens()
390 .filter_map(|it| it.into_token()) 390 .filter_map(|it| it.into_token())
391 .skip_while(|x| x.kind() != T![:]) 391 .skip_while(|x| x.kind() != T![:])
392 .filter_map(ast::Lifetime::cast) 392 .filter(|it| it.kind() == T![lifetime])
393 } 393 }
394} 394}
395 395
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs
index 293f91c2e..3950e2b7f 100644
--- a/crates/ra_syntax/src/ast/generated/tokens.rs
+++ b/crates/ra_syntax/src/ast/generated/tokens.rs
@@ -6,1246 +6,6 @@ use crate::{
6 SyntaxToken, 6 SyntaxToken,
7}; 7};
8#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9pub struct Semi {
10 pub(crate) syntax: SyntaxToken,
11}
12impl std::fmt::Display for Semi {
13 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
14 std::fmt::Display::fmt(&self.syntax, f)
15 }
16}
17impl AstToken for Semi {
18 fn can_cast(kind: SyntaxKind) -> bool { kind == SEMI }
19 fn cast(syntax: SyntaxToken) -> Option<Self> {
20 if Self::can_cast(syntax.kind()) {
21 Some(Self { syntax })
22 } else {
23 None
24 }
25 }
26 fn syntax(&self) -> &SyntaxToken { &self.syntax }
27}
28#[derive(Debug, Clone, PartialEq, Eq, Hash)]
29pub struct Comma {
30 pub(crate) syntax: SyntaxToken,
31}
32impl std::fmt::Display for Comma {
33 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
34 std::fmt::Display::fmt(&self.syntax, f)
35 }
36}
37impl AstToken for Comma {
38 fn can_cast(kind: SyntaxKind) -> bool { kind == COMMA }
39 fn cast(syntax: SyntaxToken) -> Option<Self> {
40 if Self::can_cast(syntax.kind()) {
41 Some(Self { syntax })
42 } else {
43 None
44 }
45 }
46 fn syntax(&self) -> &SyntaxToken { &self.syntax }
47}
48#[derive(Debug, Clone, PartialEq, Eq, Hash)]
49pub struct LParen {
50 pub(crate) syntax: SyntaxToken,
51}
52impl std::fmt::Display for LParen {
53 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
54 std::fmt::Display::fmt(&self.syntax, f)
55 }
56}
57impl AstToken for LParen {
58 fn can_cast(kind: SyntaxKind) -> bool { kind == L_PAREN }
59 fn cast(syntax: SyntaxToken) -> Option<Self> {
60 if Self::can_cast(syntax.kind()) {
61 Some(Self { syntax })
62 } else {
63 None
64 }
65 }
66 fn syntax(&self) -> &SyntaxToken { &self.syntax }
67}
68#[derive(Debug, Clone, PartialEq, Eq, Hash)]
69pub struct RParen {
70 pub(crate) syntax: SyntaxToken,
71}
72impl std::fmt::Display for RParen {
73 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
74 std::fmt::Display::fmt(&self.syntax, f)
75 }
76}
77impl AstToken for RParen {
78 fn can_cast(kind: SyntaxKind) -> bool { kind == R_PAREN }
79 fn cast(syntax: SyntaxToken) -> Option<Self> {
80 if Self::can_cast(syntax.kind()) {
81 Some(Self { syntax })
82 } else {
83 None
84 }
85 }
86 fn syntax(&self) -> &SyntaxToken { &self.syntax }
87}
88#[derive(Debug, Clone, PartialEq, Eq, Hash)]
89pub struct LCurly {
90 pub(crate) syntax: SyntaxToken,
91}
92impl std::fmt::Display for LCurly {
93 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
94 std::fmt::Display::fmt(&self.syntax, f)
95 }
96}
97impl AstToken for LCurly {
98 fn can_cast(kind: SyntaxKind) -> bool { kind == L_CURLY }
99 fn cast(syntax: SyntaxToken) -> Option<Self> {
100 if Self::can_cast(syntax.kind()) {
101 Some(Self { syntax })
102 } else {
103 None
104 }
105 }
106 fn syntax(&self) -> &SyntaxToken { &self.syntax }
107}
108#[derive(Debug, Clone, PartialEq, Eq, Hash)]
109pub struct RCurly {
110 pub(crate) syntax: SyntaxToken,
111}
112impl std::fmt::Display for RCurly {
113 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
114 std::fmt::Display::fmt(&self.syntax, f)
115 }
116}
117impl AstToken for RCurly {
118 fn can_cast(kind: SyntaxKind) -> bool { kind == R_CURLY }
119 fn cast(syntax: SyntaxToken) -> Option<Self> {
120 if Self::can_cast(syntax.kind()) {
121 Some(Self { syntax })
122 } else {
123 None
124 }
125 }
126 fn syntax(&self) -> &SyntaxToken { &self.syntax }
127}
128#[derive(Debug, Clone, PartialEq, Eq, Hash)]
129pub struct LBrack {
130 pub(crate) syntax: SyntaxToken,
131}
132impl std::fmt::Display for LBrack {
133 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
134 std::fmt::Display::fmt(&self.syntax, f)
135 }
136}
137impl AstToken for LBrack {
138 fn can_cast(kind: SyntaxKind) -> bool { kind == L_BRACK }
139 fn cast(syntax: SyntaxToken) -> Option<Self> {
140 if Self::can_cast(syntax.kind()) {
141 Some(Self { syntax })
142 } else {
143 None
144 }
145 }
146 fn syntax(&self) -> &SyntaxToken { &self.syntax }
147}
148#[derive(Debug, Clone, PartialEq, Eq, Hash)]
149pub struct RBrack {
150 pub(crate) syntax: SyntaxToken,
151}
152impl std::fmt::Display for RBrack {
153 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
154 std::fmt::Display::fmt(&self.syntax, f)
155 }
156}
157impl AstToken for RBrack {
158 fn can_cast(kind: SyntaxKind) -> bool { kind == R_BRACK }
159 fn cast(syntax: SyntaxToken) -> Option<Self> {
160 if Self::can_cast(syntax.kind()) {
161 Some(Self { syntax })
162 } else {
163 None
164 }
165 }
166 fn syntax(&self) -> &SyntaxToken { &self.syntax }
167}
168#[derive(Debug, Clone, PartialEq, Eq, Hash)]
169pub struct LAngle {
170 pub(crate) syntax: SyntaxToken,
171}
172impl std::fmt::Display for LAngle {
173 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
174 std::fmt::Display::fmt(&self.syntax, f)
175 }
176}
177impl AstToken for LAngle {
178 fn can_cast(kind: SyntaxKind) -> bool { kind == L_ANGLE }
179 fn cast(syntax: SyntaxToken) -> Option<Self> {
180 if Self::can_cast(syntax.kind()) {
181 Some(Self { syntax })
182 } else {
183 None
184 }
185 }
186 fn syntax(&self) -> &SyntaxToken { &self.syntax }
187}
188#[derive(Debug, Clone, PartialEq, Eq, Hash)]
189pub struct RAngle {
190 pub(crate) syntax: SyntaxToken,
191}
192impl std::fmt::Display for RAngle {
193 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
194 std::fmt::Display::fmt(&self.syntax, f)
195 }
196}
197impl AstToken for RAngle {
198 fn can_cast(kind: SyntaxKind) -> bool { kind == R_ANGLE }
199 fn cast(syntax: SyntaxToken) -> Option<Self> {
200 if Self::can_cast(syntax.kind()) {
201 Some(Self { syntax })
202 } else {
203 None
204 }
205 }
206 fn syntax(&self) -> &SyntaxToken { &self.syntax }
207}
208#[derive(Debug, Clone, PartialEq, Eq, Hash)]
209pub struct At {
210 pub(crate) syntax: SyntaxToken,
211}
212impl std::fmt::Display for At {
213 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
214 std::fmt::Display::fmt(&self.syntax, f)
215 }
216}
217impl AstToken for At {
218 fn can_cast(kind: SyntaxKind) -> bool { kind == AT }
219 fn cast(syntax: SyntaxToken) -> Option<Self> {
220 if Self::can_cast(syntax.kind()) {
221 Some(Self { syntax })
222 } else {
223 None
224 }
225 }
226 fn syntax(&self) -> &SyntaxToken { &self.syntax }
227}
228#[derive(Debug, Clone, PartialEq, Eq, Hash)]
229pub struct Pound {
230 pub(crate) syntax: SyntaxToken,
231}
232impl std::fmt::Display for Pound {
233 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
234 std::fmt::Display::fmt(&self.syntax, f)
235 }
236}
237impl AstToken for Pound {
238 fn can_cast(kind: SyntaxKind) -> bool { kind == POUND }
239 fn cast(syntax: SyntaxToken) -> Option<Self> {
240 if Self::can_cast(syntax.kind()) {
241 Some(Self { syntax })
242 } else {
243 None
244 }
245 }
246 fn syntax(&self) -> &SyntaxToken { &self.syntax }
247}
248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
249pub struct Tilde {
250 pub(crate) syntax: SyntaxToken,
251}
252impl std::fmt::Display for Tilde {
253 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
254 std::fmt::Display::fmt(&self.syntax, f)
255 }
256}
257impl AstToken for Tilde {
258 fn can_cast(kind: SyntaxKind) -> bool { kind == TILDE }
259 fn cast(syntax: SyntaxToken) -> Option<Self> {
260 if Self::can_cast(syntax.kind()) {
261 Some(Self { syntax })
262 } else {
263 None
264 }
265 }
266 fn syntax(&self) -> &SyntaxToken { &self.syntax }
267}
268#[derive(Debug, Clone, PartialEq, Eq, Hash)]
269pub struct Question {
270 pub(crate) syntax: SyntaxToken,
271}
272impl std::fmt::Display for Question {
273 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
274 std::fmt::Display::fmt(&self.syntax, f)
275 }
276}
277impl AstToken for Question {
278 fn can_cast(kind: SyntaxKind) -> bool { kind == QUESTION }
279 fn cast(syntax: SyntaxToken) -> Option<Self> {
280 if Self::can_cast(syntax.kind()) {
281 Some(Self { syntax })
282 } else {
283 None
284 }
285 }
286 fn syntax(&self) -> &SyntaxToken { &self.syntax }
287}
288#[derive(Debug, Clone, PartialEq, Eq, Hash)]
289pub struct Dollar {
290 pub(crate) syntax: SyntaxToken,
291}
292impl std::fmt::Display for Dollar {
293 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
294 std::fmt::Display::fmt(&self.syntax, f)
295 }
296}
297impl AstToken for Dollar {
298 fn can_cast(kind: SyntaxKind) -> bool { kind == DOLLAR }
299 fn cast(syntax: SyntaxToken) -> Option<Self> {
300 if Self::can_cast(syntax.kind()) {
301 Some(Self { syntax })
302 } else {
303 None
304 }
305 }
306 fn syntax(&self) -> &SyntaxToken { &self.syntax }
307}
308#[derive(Debug, Clone, PartialEq, Eq, Hash)]
309pub struct Amp {
310 pub(crate) syntax: SyntaxToken,
311}
312impl std::fmt::Display for Amp {
313 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
314 std::fmt::Display::fmt(&self.syntax, f)
315 }
316}
317impl AstToken for Amp {
318 fn can_cast(kind: SyntaxKind) -> bool { kind == AMP }
319 fn cast(syntax: SyntaxToken) -> Option<Self> {
320 if Self::can_cast(syntax.kind()) {
321 Some(Self { syntax })
322 } else {
323 None
324 }
325 }
326 fn syntax(&self) -> &SyntaxToken { &self.syntax }
327}
328#[derive(Debug, Clone, PartialEq, Eq, Hash)]
329pub struct Pipe {
330 pub(crate) syntax: SyntaxToken,
331}
332impl std::fmt::Display for Pipe {
333 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
334 std::fmt::Display::fmt(&self.syntax, f)
335 }
336}
337impl AstToken for Pipe {
338 fn can_cast(kind: SyntaxKind) -> bool { kind == PIPE }
339 fn cast(syntax: SyntaxToken) -> Option<Self> {
340 if Self::can_cast(syntax.kind()) {
341 Some(Self { syntax })
342 } else {
343 None
344 }
345 }
346 fn syntax(&self) -> &SyntaxToken { &self.syntax }
347}
348#[derive(Debug, Clone, PartialEq, Eq, Hash)]
349pub struct Plus {
350 pub(crate) syntax: SyntaxToken,
351}
352impl std::fmt::Display for Plus {
353 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
354 std::fmt::Display::fmt(&self.syntax, f)
355 }
356}
357impl AstToken for Plus {
358 fn can_cast(kind: SyntaxKind) -> bool { kind == PLUS }
359 fn cast(syntax: SyntaxToken) -> Option<Self> {
360 if Self::can_cast(syntax.kind()) {
361 Some(Self { syntax })
362 } else {
363 None
364 }
365 }
366 fn syntax(&self) -> &SyntaxToken { &self.syntax }
367}
368#[derive(Debug, Clone, PartialEq, Eq, Hash)]
369pub struct Star {
370 pub(crate) syntax: SyntaxToken,
371}
372impl std::fmt::Display for Star {
373 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
374 std::fmt::Display::fmt(&self.syntax, f)
375 }
376}
377impl AstToken for Star {
378 fn can_cast(kind: SyntaxKind) -> bool { kind == STAR }
379 fn cast(syntax: SyntaxToken) -> Option<Self> {
380 if Self::can_cast(syntax.kind()) {
381 Some(Self { syntax })
382 } else {
383 None
384 }
385 }
386 fn syntax(&self) -> &SyntaxToken { &self.syntax }
387}
388#[derive(Debug, Clone, PartialEq, Eq, Hash)]
389pub struct Slash {
390 pub(crate) syntax: SyntaxToken,
391}
392impl std::fmt::Display for Slash {
393 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
394 std::fmt::Display::fmt(&self.syntax, f)
395 }
396}
397impl AstToken for Slash {
398 fn can_cast(kind: SyntaxKind) -> bool { kind == SLASH }
399 fn cast(syntax: SyntaxToken) -> Option<Self> {
400 if Self::can_cast(syntax.kind()) {
401 Some(Self { syntax })
402 } else {
403 None
404 }
405 }
406 fn syntax(&self) -> &SyntaxToken { &self.syntax }
407}
408#[derive(Debug, Clone, PartialEq, Eq, Hash)]
409pub struct Caret {
410 pub(crate) syntax: SyntaxToken,
411}
412impl std::fmt::Display for Caret {
413 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
414 std::fmt::Display::fmt(&self.syntax, f)
415 }
416}
417impl AstToken for Caret {
418 fn can_cast(kind: SyntaxKind) -> bool { kind == CARET }
419 fn cast(syntax: SyntaxToken) -> Option<Self> {
420 if Self::can_cast(syntax.kind()) {
421 Some(Self { syntax })
422 } else {
423 None
424 }
425 }
426 fn syntax(&self) -> &SyntaxToken { &self.syntax }
427}
428#[derive(Debug, Clone, PartialEq, Eq, Hash)]
429pub struct Percent {
430 pub(crate) syntax: SyntaxToken,
431}
432impl std::fmt::Display for Percent {
433 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
434 std::fmt::Display::fmt(&self.syntax, f)
435 }
436}
437impl AstToken for Percent {
438 fn can_cast(kind: SyntaxKind) -> bool { kind == PERCENT }
439 fn cast(syntax: SyntaxToken) -> Option<Self> {
440 if Self::can_cast(syntax.kind()) {
441 Some(Self { syntax })
442 } else {
443 None
444 }
445 }
446 fn syntax(&self) -> &SyntaxToken { &self.syntax }
447}
448#[derive(Debug, Clone, PartialEq, Eq, Hash)]
449pub struct Underscore {
450 pub(crate) syntax: SyntaxToken,
451}
452impl std::fmt::Display for Underscore {
453 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
454 std::fmt::Display::fmt(&self.syntax, f)
455 }
456}
457impl AstToken for Underscore {
458 fn can_cast(kind: SyntaxKind) -> bool { kind == UNDERSCORE }
459 fn cast(syntax: SyntaxToken) -> Option<Self> {
460 if Self::can_cast(syntax.kind()) {
461 Some(Self { syntax })
462 } else {
463 None
464 }
465 }
466 fn syntax(&self) -> &SyntaxToken { &self.syntax }
467}
468#[derive(Debug, Clone, PartialEq, Eq, Hash)]
469pub struct Dot {
470 pub(crate) syntax: SyntaxToken,
471}
472impl std::fmt::Display for Dot {
473 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
474 std::fmt::Display::fmt(&self.syntax, f)
475 }
476}
477impl AstToken for Dot {
478 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT }
479 fn cast(syntax: SyntaxToken) -> Option<Self> {
480 if Self::can_cast(syntax.kind()) {
481 Some(Self { syntax })
482 } else {
483 None
484 }
485 }
486 fn syntax(&self) -> &SyntaxToken { &self.syntax }
487}
488#[derive(Debug, Clone, PartialEq, Eq, Hash)]
489pub struct Dotdot {
490 pub(crate) syntax: SyntaxToken,
491}
492impl std::fmt::Display for Dotdot {
493 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
494 std::fmt::Display::fmt(&self.syntax, f)
495 }
496}
497impl AstToken for Dotdot {
498 fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOT }
499 fn cast(syntax: SyntaxToken) -> Option<Self> {
500 if Self::can_cast(syntax.kind()) {
501 Some(Self { syntax })
502 } else {
503 None
504 }
505 }
506 fn syntax(&self) -> &SyntaxToken { &self.syntax }
507}
508#[derive(Debug, Clone, PartialEq, Eq, Hash)]
509pub struct Dotdotdot {
510 pub(crate) syntax: SyntaxToken,
511}
512impl std::fmt::Display for Dotdotdot {
513 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
514 std::fmt::Display::fmt(&self.syntax, f)
515 }
516}
517impl AstToken for Dotdotdot {
518 fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOTDOT }
519 fn cast(syntax: SyntaxToken) -> Option<Self> {
520 if Self::can_cast(syntax.kind()) {
521 Some(Self { syntax })
522 } else {
523 None
524 }
525 }
526 fn syntax(&self) -> &SyntaxToken { &self.syntax }
527}
528#[derive(Debug, Clone, PartialEq, Eq, Hash)]
529pub struct Dotdoteq {
530 pub(crate) syntax: SyntaxToken,
531}
532impl std::fmt::Display for Dotdoteq {
533 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
534 std::fmt::Display::fmt(&self.syntax, f)
535 }
536}
537impl AstToken for Dotdoteq {
538 fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOTEQ }
539 fn cast(syntax: SyntaxToken) -> Option<Self> {
540 if Self::can_cast(syntax.kind()) {
541 Some(Self { syntax })
542 } else {
543 None
544 }
545 }
546 fn syntax(&self) -> &SyntaxToken { &self.syntax }
547}
548#[derive(Debug, Clone, PartialEq, Eq, Hash)]
549pub struct Colon {
550 pub(crate) syntax: SyntaxToken,
551}
552impl std::fmt::Display for Colon {
553 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
554 std::fmt::Display::fmt(&self.syntax, f)
555 }
556}
557impl AstToken for Colon {
558 fn can_cast(kind: SyntaxKind) -> bool { kind == COLON }
559 fn cast(syntax: SyntaxToken) -> Option<Self> {
560 if Self::can_cast(syntax.kind()) {
561 Some(Self { syntax })
562 } else {
563 None
564 }
565 }
566 fn syntax(&self) -> &SyntaxToken { &self.syntax }
567}
568#[derive(Debug, Clone, PartialEq, Eq, Hash)]
569pub struct Coloncolon {
570 pub(crate) syntax: SyntaxToken,
571}
572impl std::fmt::Display for Coloncolon {
573 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
574 std::fmt::Display::fmt(&self.syntax, f)
575 }
576}
577impl AstToken for Coloncolon {
578 fn can_cast(kind: SyntaxKind) -> bool { kind == COLONCOLON }
579 fn cast(syntax: SyntaxToken) -> Option<Self> {
580 if Self::can_cast(syntax.kind()) {
581 Some(Self { syntax })
582 } else {
583 None
584 }
585 }
586 fn syntax(&self) -> &SyntaxToken { &self.syntax }
587}
588#[derive(Debug, Clone, PartialEq, Eq, Hash)]
589pub struct Eq {
590 pub(crate) syntax: SyntaxToken,
591}
592impl std::fmt::Display for Eq {
593 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
594 std::fmt::Display::fmt(&self.syntax, f)
595 }
596}
597impl AstToken for Eq {
598 fn can_cast(kind: SyntaxKind) -> bool { kind == EQ }
599 fn cast(syntax: SyntaxToken) -> Option<Self> {
600 if Self::can_cast(syntax.kind()) {
601 Some(Self { syntax })
602 } else {
603 None
604 }
605 }
606 fn syntax(&self) -> &SyntaxToken { &self.syntax }
607}
608#[derive(Debug, Clone, PartialEq, Eq, Hash)]
609pub struct Eqeq {
610 pub(crate) syntax: SyntaxToken,
611}
612impl std::fmt::Display for Eqeq {
613 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
614 std::fmt::Display::fmt(&self.syntax, f)
615 }
616}
617impl AstToken for Eqeq {
618 fn can_cast(kind: SyntaxKind) -> bool { kind == EQEQ }
619 fn cast(syntax: SyntaxToken) -> Option<Self> {
620 if Self::can_cast(syntax.kind()) {
621 Some(Self { syntax })
622 } else {
623 None
624 }
625 }
626 fn syntax(&self) -> &SyntaxToken { &self.syntax }
627}
628#[derive(Debug, Clone, PartialEq, Eq, Hash)]
629pub struct FatArrow {
630 pub(crate) syntax: SyntaxToken,
631}
632impl std::fmt::Display for FatArrow {
633 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
634 std::fmt::Display::fmt(&self.syntax, f)
635 }
636}
637impl AstToken for FatArrow {
638 fn can_cast(kind: SyntaxKind) -> bool { kind == FAT_ARROW }
639 fn cast(syntax: SyntaxToken) -> Option<Self> {
640 if Self::can_cast(syntax.kind()) {
641 Some(Self { syntax })
642 } else {
643 None
644 }
645 }
646 fn syntax(&self) -> &SyntaxToken { &self.syntax }
647}
648#[derive(Debug, Clone, PartialEq, Eq, Hash)]
649pub struct Excl {
650 pub(crate) syntax: SyntaxToken,
651}
652impl std::fmt::Display for Excl {
653 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
654 std::fmt::Display::fmt(&self.syntax, f)
655 }
656}
657impl AstToken for Excl {
658 fn can_cast(kind: SyntaxKind) -> bool { kind == EXCL }
659 fn cast(syntax: SyntaxToken) -> Option<Self> {
660 if Self::can_cast(syntax.kind()) {
661 Some(Self { syntax })
662 } else {
663 None
664 }
665 }
666 fn syntax(&self) -> &SyntaxToken { &self.syntax }
667}
668#[derive(Debug, Clone, PartialEq, Eq, Hash)]
669pub struct Neq {
670 pub(crate) syntax: SyntaxToken,
671}
672impl std::fmt::Display for Neq {
673 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
674 std::fmt::Display::fmt(&self.syntax, f)
675 }
676}
677impl AstToken for Neq {
678 fn can_cast(kind: SyntaxKind) -> bool { kind == NEQ }
679 fn cast(syntax: SyntaxToken) -> Option<Self> {
680 if Self::can_cast(syntax.kind()) {
681 Some(Self { syntax })
682 } else {
683 None
684 }
685 }
686 fn syntax(&self) -> &SyntaxToken { &self.syntax }
687}
688#[derive(Debug, Clone, PartialEq, Eq, Hash)]
689pub struct Minus {
690 pub(crate) syntax: SyntaxToken,
691}
692impl std::fmt::Display for Minus {
693 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
694 std::fmt::Display::fmt(&self.syntax, f)
695 }
696}
697impl AstToken for Minus {
698 fn can_cast(kind: SyntaxKind) -> bool { kind == MINUS }
699 fn cast(syntax: SyntaxToken) -> Option<Self> {
700 if Self::can_cast(syntax.kind()) {
701 Some(Self { syntax })
702 } else {
703 None
704 }
705 }
706 fn syntax(&self) -> &SyntaxToken { &self.syntax }
707}
708#[derive(Debug, Clone, PartialEq, Eq, Hash)]
709pub struct ThinArrow {
710 pub(crate) syntax: SyntaxToken,
711}
712impl std::fmt::Display for ThinArrow {
713 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
714 std::fmt::Display::fmt(&self.syntax, f)
715 }
716}
717impl AstToken for ThinArrow {
718 fn can_cast(kind: SyntaxKind) -> bool { kind == THIN_ARROW }
719 fn cast(syntax: SyntaxToken) -> Option<Self> {
720 if Self::can_cast(syntax.kind()) {
721 Some(Self { syntax })
722 } else {
723 None
724 }
725 }
726 fn syntax(&self) -> &SyntaxToken { &self.syntax }
727}
728#[derive(Debug, Clone, PartialEq, Eq, Hash)]
729pub struct Lteq {
730 pub(crate) syntax: SyntaxToken,
731}
732impl std::fmt::Display for Lteq {
733 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
734 std::fmt::Display::fmt(&self.syntax, f)
735 }
736}
737impl AstToken for Lteq {
738 fn can_cast(kind: SyntaxKind) -> bool { kind == LTEQ }
739 fn cast(syntax: SyntaxToken) -> Option<Self> {
740 if Self::can_cast(syntax.kind()) {
741 Some(Self { syntax })
742 } else {
743 None
744 }
745 }
746 fn syntax(&self) -> &SyntaxToken { &self.syntax }
747}
748#[derive(Debug, Clone, PartialEq, Eq, Hash)]
749pub struct Gteq {
750 pub(crate) syntax: SyntaxToken,
751}
752impl std::fmt::Display for Gteq {
753 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
754 std::fmt::Display::fmt(&self.syntax, f)
755 }
756}
757impl AstToken for Gteq {
758 fn can_cast(kind: SyntaxKind) -> bool { kind == GTEQ }
759 fn cast(syntax: SyntaxToken) -> Option<Self> {
760 if Self::can_cast(syntax.kind()) {
761 Some(Self { syntax })
762 } else {
763 None
764 }
765 }
766 fn syntax(&self) -> &SyntaxToken { &self.syntax }
767}
768#[derive(Debug, Clone, PartialEq, Eq, Hash)]
769pub struct Pluseq {
770 pub(crate) syntax: SyntaxToken,
771}
772impl std::fmt::Display for Pluseq {
773 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
774 std::fmt::Display::fmt(&self.syntax, f)
775 }
776}
777impl AstToken for Pluseq {
778 fn can_cast(kind: SyntaxKind) -> bool { kind == PLUSEQ }
779 fn cast(syntax: SyntaxToken) -> Option<Self> {
780 if Self::can_cast(syntax.kind()) {
781 Some(Self { syntax })
782 } else {
783 None
784 }
785 }
786 fn syntax(&self) -> &SyntaxToken { &self.syntax }
787}
788#[derive(Debug, Clone, PartialEq, Eq, Hash)]
789pub struct Minuseq {
790 pub(crate) syntax: SyntaxToken,
791}
792impl std::fmt::Display for Minuseq {
793 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
794 std::fmt::Display::fmt(&self.syntax, f)
795 }
796}
797impl AstToken for Minuseq {
798 fn can_cast(kind: SyntaxKind) -> bool { kind == MINUSEQ }
799 fn cast(syntax: SyntaxToken) -> Option<Self> {
800 if Self::can_cast(syntax.kind()) {
801 Some(Self { syntax })
802 } else {
803 None
804 }
805 }
806 fn syntax(&self) -> &SyntaxToken { &self.syntax }
807}
808#[derive(Debug, Clone, PartialEq, Eq, Hash)]
809pub struct Pipeeq {
810 pub(crate) syntax: SyntaxToken,
811}
812impl std::fmt::Display for Pipeeq {
813 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
814 std::fmt::Display::fmt(&self.syntax, f)
815 }
816}
817impl AstToken for Pipeeq {
818 fn can_cast(kind: SyntaxKind) -> bool { kind == PIPEEQ }
819 fn cast(syntax: SyntaxToken) -> Option<Self> {
820 if Self::can_cast(syntax.kind()) {
821 Some(Self { syntax })
822 } else {
823 None
824 }
825 }
826 fn syntax(&self) -> &SyntaxToken { &self.syntax }
827}
828#[derive(Debug, Clone, PartialEq, Eq, Hash)]
829pub struct Ampeq {
830 pub(crate) syntax: SyntaxToken,
831}
832impl std::fmt::Display for Ampeq {
833 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
834 std::fmt::Display::fmt(&self.syntax, f)
835 }
836}
837impl AstToken for Ampeq {
838 fn can_cast(kind: SyntaxKind) -> bool { kind == AMPEQ }
839 fn cast(syntax: SyntaxToken) -> Option<Self> {
840 if Self::can_cast(syntax.kind()) {
841 Some(Self { syntax })
842 } else {
843 None
844 }
845 }
846 fn syntax(&self) -> &SyntaxToken { &self.syntax }
847}
848#[derive(Debug, Clone, PartialEq, Eq, Hash)]
849pub struct Careteq {
850 pub(crate) syntax: SyntaxToken,
851}
852impl std::fmt::Display for Careteq {
853 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
854 std::fmt::Display::fmt(&self.syntax, f)
855 }
856}
857impl AstToken for Careteq {
858 fn can_cast(kind: SyntaxKind) -> bool { kind == CARETEQ }
859 fn cast(syntax: SyntaxToken) -> Option<Self> {
860 if Self::can_cast(syntax.kind()) {
861 Some(Self { syntax })
862 } else {
863 None
864 }
865 }
866 fn syntax(&self) -> &SyntaxToken { &self.syntax }
867}
868#[derive(Debug, Clone, PartialEq, Eq, Hash)]
869pub struct Slasheq {
870 pub(crate) syntax: SyntaxToken,
871}
872impl std::fmt::Display for Slasheq {
873 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
874 std::fmt::Display::fmt(&self.syntax, f)
875 }
876}
877impl AstToken for Slasheq {
878 fn can_cast(kind: SyntaxKind) -> bool { kind == SLASHEQ }
879 fn cast(syntax: SyntaxToken) -> Option<Self> {
880 if Self::can_cast(syntax.kind()) {
881 Some(Self { syntax })
882 } else {
883 None
884 }
885 }
886 fn syntax(&self) -> &SyntaxToken { &self.syntax }
887}
888#[derive(Debug, Clone, PartialEq, Eq, Hash)]
889pub struct Stareq {
890 pub(crate) syntax: SyntaxToken,
891}
892impl std::fmt::Display for Stareq {
893 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
894 std::fmt::Display::fmt(&self.syntax, f)
895 }
896}
897impl AstToken for Stareq {
898 fn can_cast(kind: SyntaxKind) -> bool { kind == STAREQ }
899 fn cast(syntax: SyntaxToken) -> Option<Self> {
900 if Self::can_cast(syntax.kind()) {
901 Some(Self { syntax })
902 } else {
903 None
904 }
905 }
906 fn syntax(&self) -> &SyntaxToken { &self.syntax }
907}
908#[derive(Debug, Clone, PartialEq, Eq, Hash)]
909pub struct Percenteq {
910 pub(crate) syntax: SyntaxToken,
911}
912impl std::fmt::Display for Percenteq {
913 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
914 std::fmt::Display::fmt(&self.syntax, f)
915 }
916}
917impl AstToken for Percenteq {
918 fn can_cast(kind: SyntaxKind) -> bool { kind == PERCENTEQ }
919 fn cast(syntax: SyntaxToken) -> Option<Self> {
920 if Self::can_cast(syntax.kind()) {
921 Some(Self { syntax })
922 } else {
923 None
924 }
925 }
926 fn syntax(&self) -> &SyntaxToken { &self.syntax }
927}
928#[derive(Debug, Clone, PartialEq, Eq, Hash)]
929pub struct Ampamp {
930 pub(crate) syntax: SyntaxToken,
931}
932impl std::fmt::Display for Ampamp {
933 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
934 std::fmt::Display::fmt(&self.syntax, f)
935 }
936}
937impl AstToken for Ampamp {
938 fn can_cast(kind: SyntaxKind) -> bool { kind == AMPAMP }
939 fn cast(syntax: SyntaxToken) -> Option<Self> {
940 if Self::can_cast(syntax.kind()) {
941 Some(Self { syntax })
942 } else {
943 None
944 }
945 }
946 fn syntax(&self) -> &SyntaxToken { &self.syntax }
947}
948#[derive(Debug, Clone, PartialEq, Eq, Hash)]
949pub struct Pipepipe {
950 pub(crate) syntax: SyntaxToken,
951}
952impl std::fmt::Display for Pipepipe {
953 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
954 std::fmt::Display::fmt(&self.syntax, f)
955 }
956}
957impl AstToken for Pipepipe {
958 fn can_cast(kind: SyntaxKind) -> bool { kind == PIPEPIPE }
959 fn cast(syntax: SyntaxToken) -> Option<Self> {
960 if Self::can_cast(syntax.kind()) {
961 Some(Self { syntax })
962 } else {
963 None
964 }
965 }
966 fn syntax(&self) -> &SyntaxToken { &self.syntax }
967}
968#[derive(Debug, Clone, PartialEq, Eq, Hash)]
969pub struct Shl {
970 pub(crate) syntax: SyntaxToken,
971}
972impl std::fmt::Display for Shl {
973 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
974 std::fmt::Display::fmt(&self.syntax, f)
975 }
976}
977impl AstToken for Shl {
978 fn can_cast(kind: SyntaxKind) -> bool { kind == SHL }
979 fn cast(syntax: SyntaxToken) -> Option<Self> {
980 if Self::can_cast(syntax.kind()) {
981 Some(Self { syntax })
982 } else {
983 None
984 }
985 }
986 fn syntax(&self) -> &SyntaxToken { &self.syntax }
987}
988#[derive(Debug, Clone, PartialEq, Eq, Hash)]
989pub struct Shr {
990 pub(crate) syntax: SyntaxToken,
991}
992impl std::fmt::Display for Shr {
993 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
994 std::fmt::Display::fmt(&self.syntax, f)
995 }
996}
997impl AstToken for Shr {
998 fn can_cast(kind: SyntaxKind) -> bool { kind == SHR }
999 fn cast(syntax: SyntaxToken) -> Option<Self> {
1000 if Self::can_cast(syntax.kind()) {
1001 Some(Self { syntax })
1002 } else {
1003 None
1004 }
1005 }
1006 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1007}
1008#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1009pub struct Shleq {
1010 pub(crate) syntax: SyntaxToken,
1011}
1012impl std::fmt::Display for Shleq {
1013 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1014 std::fmt::Display::fmt(&self.syntax, f)
1015 }
1016}
1017impl AstToken for Shleq {
1018 fn can_cast(kind: SyntaxKind) -> bool { kind == SHLEQ }
1019 fn cast(syntax: SyntaxToken) -> Option<Self> {
1020 if Self::can_cast(syntax.kind()) {
1021 Some(Self { syntax })
1022 } else {
1023 None
1024 }
1025 }
1026 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1027}
1028#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1029pub struct Shreq {
1030 pub(crate) syntax: SyntaxToken,
1031}
1032impl std::fmt::Display for Shreq {
1033 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1034 std::fmt::Display::fmt(&self.syntax, f)
1035 }
1036}
1037impl AstToken for Shreq {
1038 fn can_cast(kind: SyntaxKind) -> bool { kind == SHREQ }
1039 fn cast(syntax: SyntaxToken) -> Option<Self> {
1040 if Self::can_cast(syntax.kind()) {
1041 Some(Self { syntax })
1042 } else {
1043 None
1044 }
1045 }
1046 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1047}
1048#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1049pub struct IntNumber {
1050 pub(crate) syntax: SyntaxToken,
1051}
1052impl std::fmt::Display for IntNumber {
1053 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1054 std::fmt::Display::fmt(&self.syntax, f)
1055 }
1056}
1057impl AstToken for IntNumber {
1058 fn can_cast(kind: SyntaxKind) -> bool { kind == INT_NUMBER }
1059 fn cast(syntax: SyntaxToken) -> Option<Self> {
1060 if Self::can_cast(syntax.kind()) {
1061 Some(Self { syntax })
1062 } else {
1063 None
1064 }
1065 }
1066 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1067}
1068#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1069pub struct FloatNumber {
1070 pub(crate) syntax: SyntaxToken,
1071}
1072impl std::fmt::Display for FloatNumber {
1073 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1074 std::fmt::Display::fmt(&self.syntax, f)
1075 }
1076}
1077impl AstToken for FloatNumber {
1078 fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER }
1079 fn cast(syntax: SyntaxToken) -> Option<Self> {
1080 if Self::can_cast(syntax.kind()) {
1081 Some(Self { syntax })
1082 } else {
1083 None
1084 }
1085 }
1086 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1087}
1088#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1089pub struct Char {
1090 pub(crate) syntax: SyntaxToken,
1091}
1092impl std::fmt::Display for Char {
1093 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1094 std::fmt::Display::fmt(&self.syntax, f)
1095 }
1096}
1097impl AstToken for Char {
1098 fn can_cast(kind: SyntaxKind) -> bool { kind == CHAR }
1099 fn cast(syntax: SyntaxToken) -> Option<Self> {
1100 if Self::can_cast(syntax.kind()) {
1101 Some(Self { syntax })
1102 } else {
1103 None
1104 }
1105 }
1106 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1107}
1108#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1109pub struct Byte {
1110 pub(crate) syntax: SyntaxToken,
1111}
1112impl std::fmt::Display for Byte {
1113 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1114 std::fmt::Display::fmt(&self.syntax, f)
1115 }
1116}
1117impl AstToken for Byte {
1118 fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE }
1119 fn cast(syntax: SyntaxToken) -> Option<Self> {
1120 if Self::can_cast(syntax.kind()) {
1121 Some(Self { syntax })
1122 } else {
1123 None
1124 }
1125 }
1126 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1127}
1128#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1129pub struct String {
1130 pub(crate) syntax: SyntaxToken,
1131}
1132impl std::fmt::Display for String {
1133 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1134 std::fmt::Display::fmt(&self.syntax, f)
1135 }
1136}
1137impl AstToken for String {
1138 fn can_cast(kind: SyntaxKind) -> bool { kind == STRING }
1139 fn cast(syntax: SyntaxToken) -> Option<Self> {
1140 if Self::can_cast(syntax.kind()) {
1141 Some(Self { syntax })
1142 } else {
1143 None
1144 }
1145 }
1146 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1147}
1148#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1149pub struct RawString {
1150 pub(crate) syntax: SyntaxToken,
1151}
1152impl std::fmt::Display for RawString {
1153 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1154 std::fmt::Display::fmt(&self.syntax, f)
1155 }
1156}
1157impl AstToken for RawString {
1158 fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_STRING }
1159 fn cast(syntax: SyntaxToken) -> Option<Self> {
1160 if Self::can_cast(syntax.kind()) {
1161 Some(Self { syntax })
1162 } else {
1163 None
1164 }
1165 }
1166 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1167}
1168#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1169pub struct ByteString {
1170 pub(crate) syntax: SyntaxToken,
1171}
1172impl std::fmt::Display for ByteString {
1173 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1174 std::fmt::Display::fmt(&self.syntax, f)
1175 }
1176}
1177impl AstToken for ByteString {
1178 fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE_STRING }
1179 fn cast(syntax: SyntaxToken) -> Option<Self> {
1180 if Self::can_cast(syntax.kind()) {
1181 Some(Self { syntax })
1182 } else {
1183 None
1184 }
1185 }
1186 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1187}
1188#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1189pub struct RawByteString {
1190 pub(crate) syntax: SyntaxToken,
1191}
1192impl std::fmt::Display for RawByteString {
1193 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1194 std::fmt::Display::fmt(&self.syntax, f)
1195 }
1196}
1197impl AstToken for RawByteString {
1198 fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_BYTE_STRING }
1199 fn cast(syntax: SyntaxToken) -> Option<Self> {
1200 if Self::can_cast(syntax.kind()) {
1201 Some(Self { syntax })
1202 } else {
1203 None
1204 }
1205 }
1206 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1207}
1208#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1209pub struct Error {
1210 pub(crate) syntax: SyntaxToken,
1211}
1212impl std::fmt::Display for Error {
1213 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1214 std::fmt::Display::fmt(&self.syntax, f)
1215 }
1216}
1217impl AstToken for Error {
1218 fn can_cast(kind: SyntaxKind) -> bool { kind == ERROR }
1219 fn cast(syntax: SyntaxToken) -> Option<Self> {
1220 if Self::can_cast(syntax.kind()) {
1221 Some(Self { syntax })
1222 } else {
1223 None
1224 }
1225 }
1226 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1227}
1228#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1229pub struct Ident {
1230 pub(crate) syntax: SyntaxToken,
1231}
1232impl std::fmt::Display for Ident {
1233 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1234 std::fmt::Display::fmt(&self.syntax, f)
1235 }
1236}
1237impl AstToken for Ident {
1238 fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT }
1239 fn cast(syntax: SyntaxToken) -> Option<Self> {
1240 if Self::can_cast(syntax.kind()) {
1241 Some(Self { syntax })
1242 } else {
1243 None
1244 }
1245 }
1246 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1247}
1248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1249pub struct Whitespace { 9pub struct Whitespace {
1250 pub(crate) syntax: SyntaxToken, 10 pub(crate) syntax: SyntaxToken,
1251} 11}
@@ -1266,26 +26,6 @@ impl AstToken for Whitespace {
1266 fn syntax(&self) -> &SyntaxToken { &self.syntax } 26 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1267} 27}
1268#[derive(Debug, Clone, PartialEq, Eq, Hash)] 28#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1269pub struct Lifetime {
1270 pub(crate) syntax: SyntaxToken,
1271}
1272impl std::fmt::Display for Lifetime {
1273 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1274 std::fmt::Display::fmt(&self.syntax, f)
1275 }
1276}
1277impl AstToken for Lifetime {
1278 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME }
1279 fn cast(syntax: SyntaxToken) -> Option<Self> {
1280 if Self::can_cast(syntax.kind()) {
1281 Some(Self { syntax })
1282 } else {
1283 None
1284 }
1285 }
1286 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1287}
1288#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1289pub struct Comment { 29pub struct Comment {
1290 pub(crate) syntax: SyntaxToken, 30 pub(crate) syntax: SyntaxToken,
1291} 31}
@@ -1306,36 +46,16 @@ impl AstToken for Comment {
1306 fn syntax(&self) -> &SyntaxToken { &self.syntax } 46 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1307} 47}
1308#[derive(Debug, Clone, PartialEq, Eq, Hash)] 48#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1309pub struct Shebang { 49pub struct String {
1310 pub(crate) syntax: SyntaxToken,
1311}
1312impl std::fmt::Display for Shebang {
1313 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1314 std::fmt::Display::fmt(&self.syntax, f)
1315 }
1316}
1317impl AstToken for Shebang {
1318 fn can_cast(kind: SyntaxKind) -> bool { kind == SHEBANG }
1319 fn cast(syntax: SyntaxToken) -> Option<Self> {
1320 if Self::can_cast(syntax.kind()) {
1321 Some(Self { syntax })
1322 } else {
1323 None
1324 }
1325 }
1326 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1327}
1328#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1329pub struct LDollar {
1330 pub(crate) syntax: SyntaxToken, 50 pub(crate) syntax: SyntaxToken,
1331} 51}
1332impl std::fmt::Display for LDollar { 52impl std::fmt::Display for String {
1333 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 53 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1334 std::fmt::Display::fmt(&self.syntax, f) 54 std::fmt::Display::fmt(&self.syntax, f)
1335 } 55 }
1336} 56}
1337impl AstToken for LDollar { 57impl AstToken for String {
1338 fn can_cast(kind: SyntaxKind) -> bool { kind == L_DOLLAR } 58 fn can_cast(kind: SyntaxKind) -> bool { kind == STRING }
1339 fn cast(syntax: SyntaxToken) -> Option<Self> { 59 fn cast(syntax: SyntaxToken) -> Option<Self> {
1340 if Self::can_cast(syntax.kind()) { 60 if Self::can_cast(syntax.kind()) {
1341 Some(Self { syntax }) 61 Some(Self { syntax })
@@ -1346,16 +66,16 @@ impl AstToken for LDollar {
1346 fn syntax(&self) -> &SyntaxToken { &self.syntax } 66 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1347} 67}
1348#[derive(Debug, Clone, PartialEq, Eq, Hash)] 68#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1349pub struct RDollar { 69pub struct RawString {
1350 pub(crate) syntax: SyntaxToken, 70 pub(crate) syntax: SyntaxToken,
1351} 71}
1352impl std::fmt::Display for RDollar { 72impl std::fmt::Display for RawString {
1353 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 73 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1354 std::fmt::Display::fmt(&self.syntax, f) 74 std::fmt::Display::fmt(&self.syntax, f)
1355 } 75 }
1356} 76}
1357impl AstToken for RDollar { 77impl AstToken for RawString {
1358 fn can_cast(kind: SyntaxKind) -> bool { kind == R_DOLLAR } 78 fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_STRING }
1359 fn cast(syntax: SyntaxToken) -> Option<Self> { 79 fn cast(syntax: SyntaxToken) -> Option<Self> {
1360 if Self::can_cast(syntax.kind()) { 80 if Self::can_cast(syntax.kind()) {
1361 Some(Self { syntax }) 81 Some(Self { syntax })
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index 4ed7cf73b..4d1a290c2 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -6,6 +6,7 @@ use stdx::SepBy;
6use crate::{ 6use crate::{
7 ast::{self, support, AstChildren, AstNode, AstToken}, 7 ast::{self, support, AstChildren, AstNode, AstToken},
8 syntax_node::SyntaxElementChildren, 8 syntax_node::SyntaxElementChildren,
9 SyntaxToken, T,
9}; 10};
10 11
11pub trait TypeAscriptionOwner: AstNode { 12pub trait TypeAscriptionOwner: AstNode {
@@ -63,8 +64,8 @@ pub trait TypeBoundsOwner: AstNode {
63 support::child(self.syntax()) 64 support::child(self.syntax())
64 } 65 }
65 66
66 fn colon(&self) -> Option<ast::Colon> { 67 fn colon_token(&self) -> Option<SyntaxToken> {
67 support::token(self.syntax()) 68 support::token2(self.syntax(), T![:])
68 } 69 }
69} 70}
70 71