MCPcopy Create free account
hub / github.com/goccy/go-yaml / setLineCommentToParentMapNode

Method setLineCommentToParentMapNode

encode.go:222–240  ·  view source on GitHub ↗
(node ast.Node, filtered ast.Node, comment *ast.CommentGroupNode)

Source from the content-addressed store, hash-verified

220}
221
222func (e *Encoder) setLineCommentToParentMapNode(node ast.Node, filtered ast.Node, comment *ast.CommentGroupNode) error {
223 parent := ast.Parent(node, filtered)
224 if parent == nil {
225 return ErrUnsupportedLinePositionType(node)
226 }
227 switch p := parent.(type) {
228 case *ast.MappingValueNode:
229 if err := p.Key.SetComment(comment); err != nil {
230 return err
231 }
232 case *ast.MappingNode:
233 if err := p.SetComment(comment); err != nil {
234 return err
235 }
236 default:
237 return ErrUnsupportedLinePositionType(parent)
238 }
239 return nil
240}
241
242func (e *Encoder) setFootComment(node ast.Node, filtered ast.Node, comment *ast.CommentGroupNode) error {
243 parent := ast.Parent(node, filtered)

Callers 1

setLineCommentMethod · 0.95

Calls 3

ParentFunction · 0.92
SetCommentMethod · 0.65

Tested by

no test coverage detected