summaryrefslogtreecommitdiff
path: root/hclwrite/format.go
AgeCommit message (Collapse)Author
2024-02-16correct comment formattingRadek Simko
2024-02-15gofmtRadek Simko
2024-02-15hclwrite: Fix formatting of namespaced functionsRadek Simko
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>
2023-01-30Merge pull request #511 from hashicorp/ryancragun/formatSpaces-data-raceAlisdair McDiarmid
hclwrite: fix data race in formatSpaces()
2022-06-13hclwrite: fix data race modifying the internal "nilToken" variableTomer Heber
This global variable is supposed to be treated as immutable.
2022-02-22hclwrite: fix data race in formatSpaces()Ryan Cragun
* Fix data race in `formatSpaces()` by inlining shared state. * Run tests with the race detector enabled. Signed-off-by: Ryan Cragun <me@ryan.ec>
2020-12-02hclwrite: do not add space after a boolean NOT operatorVarun Sivapalan
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.
2019-08-09hclwrite: Do not add spaces before template control sequencesKazuma Watanabe
2019-07-24 hclwrite: Fix heredocs never close during formatnozaq
Waiting for TokenCHeredoc never ends since scanTokens() does not produce TokenNewlines inside heredocs. Related Issue: hashicorp/terraform#21434
2019-07-22hclwrite: Fix improper indent calculation inside heredocs (#107)nozaq
2019-05-15hclwrite: No spaces before ... marker in argument lists or for exprsMartin Atkins
2019-03-15hclwrite: heredoc tokens are in line.lead, not line.assign (#95)Kristin Laemmert
2019-01-16hclwrite: fix space being added between interpolated itemsAustin Burdine
closes #65 - add missing edge case for two interpolated items next to each other - add tests for both quote and heredoc cases
2018-12-14hclwrite: Formatter to put spaces before colonsMartin Atkins
The symmetrical spaces around colons in conditionals are important for familiarity with C-like languages, so we'll instead accept spaces around colons in our HCL2-unique "for expression" construct.
2018-12-14hclwrite: Suspend indentation adjustment inside heredocsMartin Atkins
Leading whitespace is significant in heredocs, so we'll avoid making any indentation adjustments for lines between OHeredoc and CHeredoc. This fixes #31.
2018-12-14hclwrite: add space between "in" keyword and expr in for expressionMartin Atkins
Our normal ruleset thinks that the "in" keyword here is a variable reference and so writes it as "in[y]". Since there's never any reason for a variable to appear immediately after another variable, we can check for a preceding identifier as a heuristic to recognize whether in is probably being used as a keyword rather than as a variable. This is not exact, but the only time this should be a false positive is if there were a syntax error in the input, and we don't make any guarantees about the result in that case anyway. This fixes #52.
2018-12-14hcl/hclsyntax: Accept single-line block definitionsMartin Atkins
This relaxes our previous spec to include a special form from HCL 1: foo { bar = baz } Although we normally require each argument to be on a line of its own, as a special case we allow a block to be defined with a single nested argument all on one line. Only one nested argument definition is allowed, and a nested block definition like "foo { bar {} }" is also disallowed in order to force the more-readable split of bar {} onto a line of its own. This is a pragmatic addition for broader compatibility with HCL 1-oriented input. This single-line usage is not considered idiomatic HCL 2 and may in future be undone by the formatter, though for now it is left as-is aside from the spacing around the braces. This also changes the behavior of the source code formatter to include spaces on both sides of braces. This mimicks the formatting behavior of HCL 1 for this situation, and (subjectively) reads better even for other one-line braced expressions like object constructors and object for expressions.
2018-07-14hclwrite: Formatter should put a space after a commaMartin Atkins
2018-07-14hclwrite: Allow format to be called on fragment of tokensMartin Atkins
2018-05-23hclwrite: Format shouldn't introduce spaces before index bracketsMartin Atkins
This is another heuristic because the "[" syntax is also the tuple constructor start marker, but this takes care of the common cases of indexing keywords and bracketed expressions. This fixes #29.
2018-01-27hclwrite: update remaining stale references to "zcl"Martin Atkins
2017-09-11Move the zcl package and its two parsing subpackages to "hcl" namesMartin Atkins
This is a super-invasive update since the "zcl" package in particular is referenced all over. There are probably still a few zcl references hanging around in comments, etc but this takes care of most of it.
2017-09-11Rename the ancillary packages from "zcl" to "hcl".Martin Atkins
The main "zcl" package requires a bit more care because of how many callers it has and because of its two subpackages, so we'll take care of that one separately.