Modifying the AST before printing?
- Dominant language
- Go
- Stars
- 5.8k
- Forks
- 657
- Avg merge
- 20h 36m
- Merged PRs (30d)
- 6
Description
Is there a way to use this HCL library to:
1. Parse a file that contains HCL (e.g. `main.tf`) to get back an AST.
1. Modify the AST in memory.
1. Write the result back out.
It seems like this should be easy, but it falls apart due to the logic in `token.Pos`. In particular, if you add a node somewhere to the AST, then all the `line` and `offset` values in the rest of the AST are wrong; and if you modify an existing node in the AST, then all the `column` and `offset` values in the rest of the AST are wrong. As a result, when you print the AST back out, you get all sorts of mangled code, especially related to comments.
Am I using this library wrong or is this just a current limitation?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.