summaryrefslogtreecommitdiff
path: root/hclwrite/ast_expression.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>
2019-11-19hclwrite: Allow constructing expressions from raw tokensMartin Atkins
We currently have functions for constructing new expressions from either constant values or from traversals, but some surgical updates require producing a more complex expression. In the long run perhaps we'll have some mechanism for constructing valid expressions via a high-level AST-like API, similar to what we already have for structural constructs, but as a simpler first step here we add a mechanism to just write raw tokens directly into an expression, with the caller being responsible for making sure those tokens represent valid HCL expression syntax. Since this new API treats the given tokens as unstructured, the resulting expression can't fully support the whole of the expression API, but it's good enough for writing in complex expressions without disturbing existing content elsewhere in the input file.
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: 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-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.