MCPcopy Index your code
hub / github.com/coder/guts / commentForFieldList

Function commentForFieldList

comments.go:117–145  ·  view source on GitHub ↗
(fl *ast.FieldList, pos token.Pos)

Source from the content-addressed store, hash-verified

115}
116
117func 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
147func covers(n ast.Node, p token.Pos) bool {
148 return n != nil && n.Pos() <= p && p <= n.End()

Callers 1

CommentForObjectFunction · 0.85

Calls 2

coversFunction · 0.85
syntheticCommentsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…