MCPcopy Create free account
hub / github.com/docker/docker-language-server / findFragments

Function findFragments

internal/compose/documentHighlight.go:149–171  ·  view source on GitHub ↗
(node ast.Node, anchors []*ast.AnchorNode, aliases []*ast.AliasNode)

Source from the content-addressed store, hash-verified

147}
148
149func findFragments(node ast.Node, anchors []*ast.AnchorNode, aliases []*ast.AliasNode) ([]*ast.AnchorNode, []*ast.AliasNode) {
150 if anchor, ok := node.(*ast.AnchorNode); ok {
151 anchors = append(anchors, anchor)
152 otherAnchors, otherAliases := findFragments(resolveAnchor(anchor), []*ast.AnchorNode{}, []*ast.AliasNode{})
153 anchors = append(anchors, otherAnchors...)
154 aliases = append(aliases, otherAliases...)
155 } else if alias, ok := node.(*ast.AliasNode); ok {
156 aliases = append(aliases, alias)
157 } else if m, ok := node.(*ast.MappingNode); ok {
158 for _, v := range m.Values {
159 otherAnchors, otherAliases := findFragments(v.Value, []*ast.AnchorNode{}, []*ast.AliasNode{})
160 anchors = append(anchors, otherAnchors...)
161 aliases = append(aliases, otherAliases...)
162 }
163 } else if s, ok := node.(*ast.SequenceNode); ok {
164 for _, item := range s.Values {
165 otherAnchors, otherAliases := findFragments(item, []*ast.AnchorNode{}, []*ast.AliasNode{})
166 anchors = append(anchors, otherAnchors...)
167 aliases = append(aliases, otherAliases...)
168 }
169 }
170 return anchors, aliases
171}
172
173func fragmentName(anchors []*ast.AnchorNode, aliases []*ast.AliasNode, line, character int) *string {
174 for i := range anchors {

Callers 1

fragmentReferenceFunction · 0.85

Calls 1

resolveAnchorFunction · 0.85

Tested by

no test coverage detected