File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -453,6 +453,7 @@ func (b *Builder) findTypesIn(pkgPath string, u *types.Universe) error {
453
453
if ok {
454
454
t := b .walkType (* u , nil , tn .Type ())
455
455
c1 := b .priorCommentLines (obj .Pos (), 1 )
456
+ // c1.Text() is safe if c1 is nil
456
457
t .CommentLines = splitLines (c1 .Text ())
457
458
if c1 == nil {
458
459
t .SecondClosestCommentLines = splitLines (b .priorCommentLines (obj .Pos (), 2 ).Text ())
@@ -463,7 +464,15 @@ func (b *Builder) findTypesIn(pkgPath string, u *types.Universe) error {
463
464
tf , ok := obj .(* tc.Func )
464
465
// We only care about functions, not concrete/abstract methods.
465
466
if ok && tf .Type () != nil && tf .Type ().(* tc.Signature ).Recv () == nil {
466
- b .addFunction (* u , nil , tf )
467
+ t := b .addFunction (* u , nil , tf )
468
+ c1 := b .priorCommentLines (obj .Pos (), 1 )
469
+ // c1.Text() is safe if c1 is nil
470
+ t .CommentLines = splitLines (c1 .Text ())
471
+ if c1 == nil {
472
+ t .SecondClosestCommentLines = splitLines (b .priorCommentLines (obj .Pos (), 2 ).Text ())
473
+ } else {
474
+ t .SecondClosestCommentLines = splitLines (b .priorCommentLines (c1 .List [0 ].Slash , 2 ).Text ())
475
+ }
467
476
}
468
477
tv , ok := obj .(* tc.Var )
469
478
if ok && ! tv .IsField () {
You can’t perform that action at this time.
0 commit comments