in internal/parser/parser_utils.go [70:98]
func buildNestedPath(topLevelBlock *hclsyntax.Block, targetNode hclsyntax.Node) string {
var pathParts []string
var traverse func(block *hclsyntax.Block, target hclsyntax.Node) bool
traverse = func(block *hclsyntax.Block, target hclsyntax.Node) bool {
for _, attr := range block.Body.Attributes {
if attr == target {
pathParts = append(pathParts, attr.Name)
return true
}
}
for _, nested := range block.Body.Blocks {
if nested == target {
pathParts = append(pathParts, nested.Type)
return true
}
if traverse(nested, target) {
pathParts = append([]string{nested.Type}, pathParts...)
return true
}
}
return false
}
if traverse(topLevelBlock, targetNode) {
return strings.Join(pathParts, ".")
}
return ""
}