in block.go [127:152]
func cleanBodyForDecode(hb *hclsyntax.Body) *hclsyntax.Body {
// Create a new hclsyntax.Body
newBody := &hclsyntax.Body{
Attributes: make(hclsyntax.Attributes),
}
// Iterate over the attributes of the original body
for attrName, attr := range hb.Attributes {
if MetaAttributeNames.Contains(attrName) {
continue
}
newBody.Attributes[attrName] = attr
}
for _, nb := range hb.Blocks {
if MetaNestedBlockNames.Contains(nb.Type) {
continue
}
cloneBody := *nb.Body
cloneNb := *nb
cloneNb.Body = cleanBodyForDecode(&cloneBody)
newBody.Blocks = append(newBody.Blocks, &cloneNb)
}
return newBody
}