(content *hcl.BodyContent)
| 52 | } |
| 53 | |
| 54 | func (w deepWrapper) transformContent(content *hcl.BodyContent) *hcl.BodyContent { |
| 55 | if len(content.Blocks) == 0 { |
| 56 | // Easy path: if there are no blocks then there are no child bodies to wrap |
| 57 | return content |
| 58 | } |
| 59 | |
| 60 | // Since we're going to change things here, we'll be polite and clone the |
| 61 | // structure so that we don't risk impacting any internal state of the |
| 62 | // original body. |
| 63 | ret := &hcl.BodyContent{ |
| 64 | Attributes: content.Attributes, |
| 65 | MissingItemRange: content.MissingItemRange, |
| 66 | Blocks: make(hcl.Blocks, len(content.Blocks)), |
| 67 | } |
| 68 | |
| 69 | for i, givenBlock := range content.Blocks { |
| 70 | // Shallow-copy the block so we can mutate it |
| 71 | newBlock := *givenBlock |
| 72 | newBlock.Body = Deep(newBlock.Body, w.Transformer) |
| 73 | ret.Blocks[i] = &newBlock |
| 74 | } |
| 75 | |
| 76 | return ret |
| 77 | } |
| 78 | |
| 79 | func (w deepWrapper) JustAttributes() (hcl.Attributes, hcl.Diagnostics) { |
| 80 | // Attributes can't have bodies or nested blocks, so this is just a thin wrapper. |
no test coverage detected