@@ -416,8 +416,35 @@ class AliasSpec extends @aliasspec, TypeSpec { }
416
416
class TypeDefSpec extends @typedefspec, TypeSpec { }
417
417
418
418
/**
419
- * A field declaration, of a struct, a function (in which case this is a parameter or result variable),
420
- * or an interface (in which case this is a method or embedding spec).
419
+ * A field declaration, in a struct, a function (for parameter or result
420
+ * variables), or an interface (in which case this is a method or embedding
421
+ * spec).
422
+ *
423
+ * Examples:
424
+ *
425
+ * ```go
426
+ * Name string `json:"name"`
427
+ * s string
428
+ * x, y int
429
+ * p *Point
430
+ * Close() error
431
+ * io.Reader
432
+ * ~int | float32
433
+ * ```
434
+ * as in the following code:
435
+ * ```go
436
+ * struct {
437
+ * io.Reader
438
+ * Name string `json:"name"`
439
+ * x, y int
440
+ * }
441
+ * func (p *Point) f(s string) (x, y int) { }
442
+ * type MyInterface interface {
443
+ * Close() error
444
+ * io.Reader
445
+ * ~int32 | float32
446
+ * }
447
+ * ```
421
448
*/
422
449
class FieldBase extends @field, ExprParent {
423
450
/**
@@ -433,6 +460,22 @@ class FieldBase extends @field, ExprParent {
433
460
434
461
/**
435
462
* A field declaration in a struct type.
463
+ *
464
+ * Examples:
465
+ *
466
+ * ```go
467
+ * Name string `json:"name"`
468
+ * x, y int
469
+ * ```
470
+ *
471
+ * as in the following code:
472
+ *
473
+ * ```go
474
+ * struct {
475
+ * Name string `json:"name"`
476
+ * x, y int
477
+ * }
478
+ * ```
436
479
*/
437
480
class FieldDecl extends FieldBase , Documentable , ExprParent {
438
481
StructTypeExpr st ;
@@ -464,6 +507,20 @@ class FieldDecl extends FieldBase, Documentable, ExprParent {
464
507
465
508
/**
466
509
* An embedded field declaration in a struct.
510
+ *
511
+ * Examples:
512
+ *
513
+ * ```go
514
+ * io.Reader
515
+ * ```
516
+ *
517
+ * as in the following code:
518
+ *
519
+ * ```go
520
+ * struct {
521
+ * io.Reader
522
+ * }
523
+ * ```
467
524
*/
468
525
class EmbeddedFieldDecl extends FieldDecl {
469
526
EmbeddedFieldDecl ( ) { not exists ( this .getNameExpr ( _) ) }
@@ -473,6 +530,20 @@ class EmbeddedFieldDecl extends FieldDecl {
473
530
474
531
/**
475
532
* A function parameter or result variable declaration.
533
+ *
534
+ * Examples:
535
+ *
536
+ * ```go
537
+ * s string
538
+ * x, y int
539
+ * ```
540
+ *
541
+ * as in the following code:
542
+ *
543
+ * ```go
544
+ * func f(s string, x, y int) { }
545
+ * func g() (s string, x, y int){ return }
546
+ * ```
476
547
*/
477
548
class ParameterOrResultDecl extends FieldBase , Documentable , ExprParent {
478
549
int rawIndex ;
@@ -507,6 +578,19 @@ class ParameterOrResultDecl extends FieldBase, Documentable, ExprParent {
507
578
508
579
/**
509
580
* A parameter declaration.
581
+ *
582
+ * Examples:
583
+ *
584
+ * ```go
585
+ * s string
586
+ * x, y int
587
+ * ```
588
+ *
589
+ * as in the following code:
590
+ *
591
+ * ```go
592
+ * func f(s string, x, y int) { }
593
+ * ```
510
594
*/
511
595
class ParameterDecl extends ParameterOrResultDecl {
512
596
ParameterDecl ( ) { rawIndex >= 0 }
@@ -524,6 +608,20 @@ class ParameterDecl extends ParameterOrResultDecl {
524
608
525
609
/**
526
610
* A receiver declaration in a function declaration.
611
+ *
612
+ * Examples:
613
+ *
614
+ * ```go
615
+ * p *Point
616
+ * r io.Reader
617
+ * ```
618
+ *
619
+ * as in the following code:
620
+ *
621
+ * ```go
622
+ * func (p *Point) f() { }
623
+ * func (r io.Reader) g() { }
624
+ * ```
527
625
*/
528
626
class ReceiverDecl extends FieldBase , Documentable , ExprParent {
529
627
FuncDecl fd ;
@@ -547,6 +645,22 @@ class ReceiverDecl extends FieldBase, Documentable, ExprParent {
547
645
548
646
/**
549
647
* A result variable declaration.
648
+ *
649
+ * Examples:
650
+ *
651
+ * ```go
652
+ * error
653
+ * r io.Reader
654
+ * x, y int
655
+ * ```
656
+ *
657
+ * as in the following code:
658
+ *
659
+ * ```go
660
+ * func f(error) { return nil }
661
+ * func g(r io.Reader) { return nil }
662
+ * func h(x, y int) { return }
663
+ * ```
550
664
*/
551
665
class ResultVariableDecl extends ParameterOrResultDecl {
552
666
ResultVariableDecl ( ) { rawIndex < 0 }
@@ -564,6 +678,22 @@ class ResultVariableDecl extends ParameterOrResultDecl {
564
678
565
679
/**
566
680
* A type parameter declaration in a type specification.
681
+ *
682
+ * Examples:
683
+ *
684
+ * ```go
685
+ * S, T comparable
686
+ * U any
687
+ * K ~int32 | float32
688
+ * _ any
689
+ * ```
690
+ *
691
+ * as in the following code:
692
+ *
693
+ * ```go
694
+ * type GenericStruct[S, T comparable, U any, K ~int32 | float32, _ any] struct { }
695
+ * func GenericFunction[S, T comparable, U any, K ~int32 | float32, _ any]() {}
696
+ * ```
567
697
*/
568
698
class TypeParamDecl extends @typeparamdecl, Documentable , ExprParent {
569
699
TypeParamDecl ( ) { typeparamdecls ( this , _, _) }
@@ -615,6 +745,24 @@ class TypeParamDecl extends @typeparamdecl, Documentable, ExprParent {
615
745
616
746
/**
617
747
* A method or embedding specification in an interface type expression.
748
+ *
749
+ * Examples:
750
+ *
751
+ * ```go
752
+ * Close() error
753
+ * io.Reader
754
+ * ~int32 | float32
755
+ * ```
756
+ *
757
+ * as in the following code:
758
+ *
759
+ * ```go
760
+ * type MyInterface interface {
761
+ * Close() error
762
+ * io.Reader
763
+ * ~int32 | float32
764
+ * }
765
+ * ```
618
766
*/
619
767
class InterfaceMemberSpec extends FieldBase , Documentable , ExprParent {
620
768
InterfaceTypeExpr ite ;
@@ -636,6 +784,20 @@ class InterfaceMemberSpec extends FieldBase, Documentable, ExprParent {
636
784
637
785
/**
638
786
* A method specification in an interface.
787
+ *
788
+ * Examples:
789
+ *
790
+ * ```go
791
+ * Close() error
792
+ * ```
793
+ *
794
+ * as in the following code:
795
+ *
796
+ * ```go
797
+ * type MyInterface interface {
798
+ * Close() error
799
+ * }
800
+ * ```
639
801
*/
640
802
class MethodSpec extends InterfaceMemberSpec {
641
803
Expr name ;
@@ -654,6 +816,22 @@ class MethodSpec extends InterfaceMemberSpec {
654
816
655
817
/**
656
818
* An embedding specification in an interface.
819
+ *
820
+ * Examples:
821
+ *
822
+ * ```go
823
+ * io.Reader
824
+ * ~int32 | float32
825
+ * ```
826
+ *
827
+ * as in the following code:
828
+ *
829
+ * ```go
830
+ * type MyInterface interface {
831
+ * io.Reader
832
+ * ~int32 | float32
833
+ * }
834
+ * ```
657
835
*/
658
836
class EmbeddingSpec extends InterfaceMemberSpec {
659
837
EmbeddingSpec ( ) { not exists ( this .getChildExpr ( 1 ) ) }
0 commit comments