@@ -216,6 +216,7 @@ pub struct SourceFile {
216
216
}
217
217
impl ast:: HasAttrs for SourceFile { }
218
218
impl ast:: HasModuleItem for SourceFile { }
219
+ impl ast:: HasDocComments for SourceFile { }
219
220
impl SourceFile {
220
221
pub fn shebang_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ shebang] ) }
221
222
}
@@ -227,6 +228,7 @@ pub struct Const {
227
228
impl ast:: HasAttrs for Const { }
228
229
impl ast:: HasName for Const { }
229
230
impl ast:: HasVisibility for Const { }
231
+ impl ast:: HasDocComments for Const { }
230
232
impl Const {
231
233
pub fn default_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ default ] ) }
232
234
pub fn const_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ const ] ) }
@@ -246,6 +248,7 @@ impl ast::HasAttrs for Enum {}
246
248
impl ast:: HasName for Enum { }
247
249
impl ast:: HasVisibility for Enum { }
248
250
impl ast:: HasGenericParams for Enum { }
251
+ impl ast:: HasDocComments for Enum { }
249
252
impl Enum {
250
253
pub fn enum_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ enum ] ) }
251
254
pub fn variant_list ( & self ) -> Option < VariantList > { support:: child ( & self . syntax ) }
@@ -283,6 +286,7 @@ impl ast::HasAttrs for Fn {}
283
286
impl ast:: HasName for Fn { }
284
287
impl ast:: HasVisibility for Fn { }
285
288
impl ast:: HasGenericParams for Fn { }
289
+ impl ast:: HasDocComments for Fn { }
286
290
impl Fn {
287
291
pub fn default_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ default ] ) }
288
292
pub fn const_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ const ] ) }
@@ -303,6 +307,7 @@ pub struct Impl {
303
307
impl ast:: HasAttrs for Impl { }
304
308
impl ast:: HasVisibility for Impl { }
305
309
impl ast:: HasGenericParams for Impl { }
310
+ impl ast:: HasDocComments for Impl { }
306
311
impl Impl {
307
312
pub fn default_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ default ] ) }
308
313
pub fn unsafe_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ unsafe ] ) }
@@ -320,6 +325,7 @@ pub struct MacroRules {
320
325
impl ast:: HasAttrs for MacroRules { }
321
326
impl ast:: HasName for MacroRules { }
322
327
impl ast:: HasVisibility for MacroRules { }
328
+ impl ast:: HasDocComments for MacroRules { }
323
329
impl MacroRules {
324
330
pub fn macro_rules_token ( & self ) -> Option < SyntaxToken > {
325
331
support:: token ( & self . syntax , T ! [ macro_rules] )
@@ -335,6 +341,7 @@ pub struct MacroDef {
335
341
impl ast:: HasAttrs for MacroDef { }
336
342
impl ast:: HasName for MacroDef { }
337
343
impl ast:: HasVisibility for MacroDef { }
344
+ impl ast:: HasDocComments for MacroDef { }
338
345
impl MacroDef {
339
346
pub fn macro_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ macro] ) }
340
347
pub fn args ( & self ) -> Option < TokenTree > { support:: child ( & self . syntax ) }
@@ -348,6 +355,7 @@ pub struct Module {
348
355
impl ast:: HasAttrs for Module { }
349
356
impl ast:: HasName for Module { }
350
357
impl ast:: HasVisibility for Module { }
358
+ impl ast:: HasDocComments for Module { }
351
359
impl Module {
352
360
pub fn mod_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ mod ] ) }
353
361
pub fn item_list ( & self ) -> Option < ItemList > { support:: child ( & self . syntax ) }
@@ -361,6 +369,7 @@ pub struct Static {
361
369
impl ast:: HasAttrs for Static { }
362
370
impl ast:: HasName for Static { }
363
371
impl ast:: HasVisibility for Static { }
372
+ impl ast:: HasDocComments for Static { }
364
373
impl Static {
365
374
pub fn static_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ static ] ) }
366
375
pub fn mut_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ mut ] ) }
@@ -379,6 +388,7 @@ impl ast::HasAttrs for Struct {}
379
388
impl ast:: HasName for Struct { }
380
389
impl ast:: HasVisibility for Struct { }
381
390
impl ast:: HasGenericParams for Struct { }
391
+ impl ast:: HasDocComments for Struct { }
382
392
impl Struct {
383
393
pub fn struct_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ struct ] ) }
384
394
pub fn semicolon_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ; ] ) }
@@ -394,6 +404,7 @@ impl ast::HasName for Trait {}
394
404
impl ast:: HasVisibility for Trait { }
395
405
impl ast:: HasGenericParams for Trait { }
396
406
impl ast:: HasTypeBounds for Trait { }
407
+ impl ast:: HasDocComments for Trait { }
397
408
impl Trait {
398
409
pub fn unsafe_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ unsafe ] ) }
399
410
pub fn auto_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ auto] ) }
@@ -410,6 +421,7 @@ impl ast::HasName for TypeAlias {}
410
421
impl ast:: HasVisibility for TypeAlias { }
411
422
impl ast:: HasGenericParams for TypeAlias { }
412
423
impl ast:: HasTypeBounds for TypeAlias { }
424
+ impl ast:: HasDocComments for TypeAlias { }
413
425
impl TypeAlias {
414
426
pub fn default_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ default ] ) }
415
427
pub fn type_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ type ] ) }
@@ -426,6 +438,7 @@ impl ast::HasAttrs for Union {}
426
438
impl ast:: HasName for Union { }
427
439
impl ast:: HasVisibility for Union { }
428
440
impl ast:: HasGenericParams for Union { }
441
+ impl ast:: HasDocComments for Union { }
429
442
impl Union {
430
443
pub fn union_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ union ] ) }
431
444
pub fn record_field_list ( & self ) -> Option < RecordFieldList > { support:: child ( & self . syntax ) }
@@ -437,6 +450,7 @@ pub struct Use {
437
450
}
438
451
impl ast:: HasAttrs for Use { }
439
452
impl ast:: HasVisibility for Use { }
453
+ impl ast:: HasDocComments for Use { }
440
454
impl Use {
441
455
pub fn use_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ use ] ) }
442
456
pub fn use_tree ( & self ) -> Option < UseTree > { support:: child ( & self . syntax ) }
@@ -582,6 +596,7 @@ pub struct RecordField {
582
596
impl ast:: HasAttrs for RecordField { }
583
597
impl ast:: HasName for RecordField { }
584
598
impl ast:: HasVisibility for RecordField { }
599
+ impl ast:: HasDocComments for RecordField { }
585
600
impl RecordField {
586
601
pub fn colon_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ : ] ) }
587
602
pub fn ty ( & self ) -> Option < Type > { support:: child ( & self . syntax ) }
@@ -593,6 +608,7 @@ pub struct TupleField {
593
608
}
594
609
impl ast:: HasAttrs for TupleField { }
595
610
impl ast:: HasVisibility for TupleField { }
611
+ impl ast:: HasDocComments for TupleField { }
596
612
impl TupleField {
597
613
pub fn ty ( & self ) -> Option < Type > { support:: child ( & self . syntax ) }
598
614
}
@@ -614,6 +630,7 @@ pub struct Variant {
614
630
impl ast:: HasAttrs for Variant { }
615
631
impl ast:: HasName for Variant { }
616
632
impl ast:: HasVisibility for Variant { }
633
+ impl ast:: HasDocComments for Variant { }
617
634
impl Variant {
618
635
pub fn field_list ( & self ) -> Option < FieldList > { support:: child ( & self . syntax ) }
619
636
pub fn eq_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ =] ) }
@@ -1567,6 +1584,7 @@ pub enum Adt {
1567
1584
Union ( Union ) ,
1568
1585
}
1569
1586
impl ast:: HasAttrs for Adt { }
1587
+ impl ast:: HasDocComments for Adt { }
1570
1588
impl ast:: HasGenericParams for Adt { }
1571
1589
impl ast:: HasName for Adt { }
1572
1590
impl ast:: HasVisibility for Adt { }
@@ -1609,6 +1627,12 @@ pub struct AnyHasAttrs {
1609
1627
}
1610
1628
impl ast:: HasAttrs for AnyHasAttrs { }
1611
1629
1630
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1631
+ pub struct AnyHasDocComments {
1632
+ pub ( crate ) syntax : SyntaxNode ,
1633
+ }
1634
+ impl ast:: HasDocComments for AnyHasDocComments { }
1635
+
1612
1636
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1613
1637
pub struct AnyHasGenericParams {
1614
1638
pub ( crate ) syntax : SyntaxNode ,
@@ -3869,6 +3893,27 @@ impl AstNode for AnyHasAttrs {
3869
3893
}
3870
3894
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
3871
3895
}
3896
+ impl AnyHasDocComments {
3897
+ #[ inline]
3898
+ pub fn new < T : ast:: HasDocComments > ( node : T ) -> AnyHasDocComments {
3899
+ AnyHasDocComments { syntax : node. syntax ( ) . clone ( ) }
3900
+ }
3901
+ }
3902
+ impl AstNode for AnyHasDocComments {
3903
+ fn can_cast ( kind : SyntaxKind ) -> bool {
3904
+ match kind {
3905
+ SOURCE_FILE | CONST | ENUM | FN | IMPL | MACRO_RULES | MACRO_DEF | MODULE | STATIC
3906
+ | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE | RECORD_FIELD | TUPLE_FIELD | VARIANT => {
3907
+ true
3908
+ }
3909
+ _ => false ,
3910
+ }
3911
+ }
3912
+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
3913
+ Self :: can_cast ( syntax. kind ( ) ) . then ( || AnyHasDocComments { syntax } )
3914
+ }
3915
+ fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
3916
+ }
3872
3917
impl AnyHasGenericParams {
3873
3918
#[ inline]
3874
3919
pub fn new < T : ast:: HasGenericParams > ( node : T ) -> AnyHasGenericParams {
0 commit comments