MCPcopy
hub / github.com/hashicorp/hcl / sourceRange

Method sourceRange

hcldec/spec.go:1002–1021  ·  view source on GitHub ↗
(content *hcl.BodyContent, blockLabels []blockLabel)

Source from the content-addressed store, hash-verified

1000}
1001
1002func (s *BlockMapSpec) sourceRange(content *hcl.BodyContent, blockLabels []blockLabel) hcl.Range {
1003 // We return the source range of the _first_ block of the given type,
1004 // since they are not guaranteed to form a contiguous range.
1005
1006 var childBlock *hcl.Block
1007 for _, candidate := range content.Blocks {
1008 if candidate.Type != s.TypeName {
1009 continue
1010 }
1011
1012 childBlock = candidate
1013 break
1014 }
1015
1016 if childBlock == nil {
1017 return content.MissingItemRange
1018 }
1019
1020 return sourceRange(childBlock.Body, labelsForBlock(childBlock), s.Nested)
1021}
1022
1023// A BlockObjectSpec is a Spec that produces a cty object of the results of
1024// decoding all of the nested blocks of a given type, using a nested spec.

Callers

nothing calls this directly

Calls 2

sourceRangeFunction · 0.85
labelsForBlockFunction · 0.85

Tested by

no test coverage detected