summaryrefslogtreecommitdiff
path: root/hclwrite/generate.go
AgeCommit message (Collapse)Author
2023-02-28[COMPLIANCE] Add Copyright and License Headers (#586)hashicorp-copywrite[bot]
* [COMPLIANCE] Add Copyright and License Headers * add copywrite file and revert headers in testdata --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Liam Cervante <liam.cervante@hashicorp.com>
2022-01-03hclwrite: Various new "TokensFor..." functionsincubator4
The "TokensFor..." family of functions all aim to construct valid raw token sequences representing particular syntax constructs. Previously we had only "leaf" functions TokensForValue and TokensForTraversal, but nothing to help with constructing compound structures. Here we add TokensForTuple, TokensForObject, and TokensForFunctionCall which together cover all of the constructs that HCL allows static analysis of, and thus constructs where it's likely that someone would want to generate an expression that is interpreted purely by its syntax and not resolved into a value. What all of these have in common is that they take other Tokens values as arguments and include them verbatim as part of their result, with the caller being responsible for making sure these smaller units are themselves valid expression tokens. This also adds TokensForIdentifier as a convenient shorthand for generating single-identifier tokens, which is particularly useful for populating the attribute names in TokensForObject.
2020-05-06hclwrite: Generate multi-line objects and mapsAlisdair McDiarmid
The previous syntax for object and map values was a single line of key-value pairs. For example: object = { bar = 5, baz = true, foo = "foo" } This is very compact, but in practice for many HCL values, less readable and less common than a multi-line object format. This commit changes the generated output from hclwrite to one line per attribute. Examples of the new format: // Empty object/map is a single line a = {} // Single-value object/map has the attribute on a separate line b = { bar = 5 } // Multi-value object/map has one line per attribute c = { bar = 5 baz = true }
2019-11-11hclwrite: fix TokensForTraversal handling of index stepsColin Hoglund
2019-09-09Unfold the "hcl" directory up into the rootMartin Atkins
The main HCL package is more visible this way, and so it's easier than having to pick it out from dozens of other package directories.
2019-09-09Change module path to github.com/hashicorp/hcl/v2Martin Atkins
This is in preparation for the first v2 release from the main HCL repository.
2018-11-04hclwrite: Implement Body.SetAttributeTraversalMartin Atkins
2018-07-14hclwrite: TokensForValueMartin Atkins
This function produces a token stream of a reasonable source representation of the given constant value.