summaryrefslogtreecommitdiff
path: root/hclwrite
AgeCommit message (Collapse)Author
2018-11-06Merge pull request #53 from hashicorp/pt/edges_from_hcl1Paul Tyng
Add additional comment test cases
2018-11-04hclwrite: Expression.RenameVariablePrefixMartin Atkins
This function serves the use-case of surgically renaming references to variables in an existing file without disturbing other tokens.
2018-11-04hclwrite: Implement Body.SetAttributeTraversalMartin Atkins
2018-11-04hclwrite: Support for creating new blocks and clearing bodiesMartin Atkins
2018-11-03hclwrite: Recast TestRoundupCreate as an exampleMartin Atkins
Since the goal of this is to be somewhat realistic of what a caller might do, we might as well also include it in the godoc examples.
2018-11-03hclwrite: NewEmptyFile functionMartin Atkins
This completes the minimal functionality for creating a new file from scratch, rather than modifying an existing one. This is illustrated by a new test TestRoundupCreate that uses the API to create a new file in a similar way to how a calling application might.
2018-11-03hclwrite: Make File and Tokens implement io.WriterToMartin Atkins
There isn't any strong reason for this -- they don't implement io.Reader and so can't be used in places where a Reader+WriterTo is expected, like io.Copy -- but go lint thinks that anything called WriteTo with an io.Writer argument is an attempt to implement WriterTo and so this just shuts up the linter.
2018-11-03hclwrite: Rename Body.AppendBlock to AppendNewBlockMartin Atkins
Since this function implicitly creates a new body, this name is more appropriate and leaves the name "AppendBlock" open for a later method to append an _existing_ block, such as when moving a block from one file to another.
2018-11-03hclwrite: Body.AppendBlockMartin Atkins
This method allows a caller to generate a nested block within a body. Since a nested block has its own content body, this now allows for deep structures to be generated.
2018-11-03hclwrite: Split Attribute and Block into their own source filesMartin Atkins
These will grow to have significant logic of their own, so hiding them at the end of the Body file makes things harder to read.
2018-10-31Add additional comment test casesPaul Tyng
Some of these fail in HCL1 fmt
2018-08-25hclwrite: Adjust token spacing automatically when writingMartin Atkins
Although our underlying parse tree retains all of the token content, it doesn't necessarily retain all of the spacing information under editing, and so formatting on save ensures that we'll produce a canonical result even if some edits have been applied that have changed the expected alignment of objects, etc.
2018-08-09hclwrite: Fix NewExpressionAbsTraversal signatureMartin Atkins
It is still not implemented, but at least now it is declared with the correct return type.
2018-08-09hclwrite: Body.SetAttributeValueMartin Atkins
For now, this is the only way to set an attribute, and so attributes can only be set to literal values. Later this will be generalized so that this is just a helper wrapper around a "SetAttribute" method that just uses a given expression, which then helps by constructing the expression from the value first.
2018-08-01hclwrite: Simplify internal data structuresMartin Atkins
The original prototype of hclwrite tried to track both the tokens and the AST as two parallel data structures. This quickly exploded in complexity, leading to lots of messy code to manage keeping those two structures in sync. This new approach melds the two structures together, creating first a physical token tree (made of "node" objects, and hidden from the caller) and then attaching the AST nodes to that token tree as additional sidecar data. The result is much easier to work with, leading to less code in the parser and considerably less complex data structures in the parser's tests. This commit is enough to reach feature parity with the previous prototype, but it remains a prototype. With a more usable foundation, we'll evolve this into a more complete implementation in subsequent commits.
2018-07-14hclwrite: TokensForValueMartin Atkins
This function produces a token stream of a reasonable source representation of the given constant value.
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-07-14hclwrite: Parsing of absolute traversals in expressionsMartin Atkins
This will allow for use-cases such as renaming a variable (changing the content of the first token) and replacing variable references with constant values that they evaluate to for debug purposes.
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
2018-01-23update zclsyntax to hclsyntax in various comments and stringsFatih Arslan
These are remnants of the project HCL was forked from.
2017-09-11Update doc comments and readmes for zcl -> HCL.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.