(fl *ast.FieldList, pos token.Pos)
| 115 | } |
| 116 | |
| 117 | func commentForFieldList(fl *ast.FieldList, pos token.Pos) []bindings.SyntheticComment { |
| 118 | if fl == nil { |
| 119 | return nil |
| 120 | } |
| 121 | cmts := []bindings.SyntheticComment{} |
| 122 | for _, fld := range fl.List { |
| 123 | if !covers(fld, pos) { |
| 124 | continue |
| 125 | } |
| 126 | // Named field or interface method: match any of the Names. |
| 127 | if len(fld.Names) > 0 { |
| 128 | for _, nm := range fld.Names { |
| 129 | if nm.Pos() == pos { |
| 130 | cmts = append(cmts, syntheticComments(true, fld.Doc)...) |
| 131 | cmts = append(cmts, syntheticComments(false, fld.Comment)...) |
| 132 | return cmts |
| 133 | } |
| 134 | } |
| 135 | } else { |
| 136 | // Embedded field (anonymous): no Names; match on the Type span. |
| 137 | if covers(fld.Type, pos) { |
| 138 | cmts = append(cmts, syntheticComments(true, fld.Doc)...) |
| 139 | cmts = append(cmts, syntheticComments(false, fld.Comment)...) |
| 140 | return cmts |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | return nil |
| 145 | } |
| 146 | |
| 147 | func covers(n ast.Node, p token.Pos) bool { |
| 148 | return n != nil && n.Pos() <= p && p <= n.End() |
no test coverage detected
searching dependent graphs…