diff options
| author | Masayuki Morita <minamijoyo@gmail.com> | 2020-01-29 14:56:39 +0900 |
|---|---|---|
| committer | Martin Atkins <mart@degeneration.co.uk> | 2020-08-21 11:30:32 -0700 |
| commit | 143a545916cd7b6998c85b05e007183eeb7df6e4 (patch) | |
| tree | bb305c76590440a502df12e75b3ace4f71aab680 /hclwrite | |
| parent | c3cbe9a9e2143e99cec25f37f3e4f3d226850e81 (diff) | |
hclwrite: Fix a bug that Block.open/close positions were not recorded in parser
While implementing Block.SetLabels(), I found a new hclwrite parser bug.
The NewBlock() method records positions of TokenOBrace / TokenCBrace.
Nevertheless when generating blocks via hclwrite.ParseConfig(),
they were not recorded.
The position of TokenOBrace is needed for Block.SetLabels(),
so I also fixed this existing bug.
Diffstat (limited to 'hclwrite')
| -rw-r--r-- | hclwrite/parser.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/hclwrite/parser.go b/hclwrite/parser.go index 354d4ea..ad5fcda 100644 --- a/hclwrite/parser.go +++ b/hclwrite/parser.go @@ -329,7 +329,7 @@ func parseBlock(nativeBlock *hclsyntax.Block, from, leadComments, lineComments, before, oBrace, from := from.Partition(nativeBlock.OpenBraceRange) children.AppendUnstructuredTokens(before.Tokens()) - children.AppendUnstructuredTokens(oBrace.Tokens()) + block.open = children.AppendUnstructuredTokens(oBrace.Tokens()) // We go a bit out of order here: we go hunting for the closing brace // so that we have a delimited body, but then we'll deal with the body @@ -342,7 +342,7 @@ func parseBlock(nativeBlock *hclsyntax.Block, from, leadComments, lineComments, children.AppendNode(body) children.AppendUnstructuredTokens(after.Tokens()) - children.AppendUnstructuredTokens(cBrace.Tokens()) + block.close = children.AppendUnstructuredTokens(cBrace.Tokens()) // stragglers children.AppendUnstructuredTokens(from.Tokens()) |
