MCPcopy
hub / github.com/hashicorp/hcl / TokensForValue

Function TokensForValue

hclwrite/generate.go:26–30  ·  view source on GitHub ↗

TokensForValue returns a sequence of tokens that represents the given constant value. This function only supports types that are used by HCL. In particular, it does not support capsule types and will panic if given one. It is not possible to express an unknown value in source code, so this functio

(val cty.Value)

Source from the content-addressed store, hash-verified

24// values. A caller can call the value's IsWhollyKnown method to verify that
25// no unknown values are present before calling TokensForValue.
26func TokensForValue(val cty.Value) Tokens {
27 toks := appendTokensForValue(val, nil)
28 format(toks) // fiddle with the SpacesBefore field to get canonical spacing
29 return toks
30}
31
32// TokensForTraversal returns a sequence of tokens that represents the given
33// traversal.

Callers 7

ReplaceMethod · 0.85
NewExpressionLiteralFunction · 0.85
TestTokensForValueFunction · 0.85
TestTokensForTupleFunction · 0.85
TestTokensForObjectFunction · 0.85

Calls 2

appendTokensForValueFunction · 0.85
formatFunction · 0.85

Tested by 5

TestTokensForValueFunction · 0.68
TestTokensForTupleFunction · 0.68
TestTokensForObjectFunction · 0.68