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

Function TokensForFunctionCall

hclwrite/generate.go:160–183  ·  view source on GitHub ↗

TokensForFunctionCall returns a sequence of tokens that represents call to the function with the given name, using the argument tokens to populate the argument expressions. TokensForFunctionCall includes the given argument tokens verbatim into the positions in the resulting call expression, without

(funcName string, args ...Tokens)

Source from the content-addressed store, hash-verified

158// manually appending a TokenEllipsis with the bytes "..." to the tokens for
159// the final argument.
160func TokensForFunctionCall(funcName string, args ...Tokens) Tokens {
161 var toks Tokens
162 toks = append(toks, TokensForIdentifier(funcName)...)
163 toks = append(toks, &Token{
164 Type: hclsyntax.TokenOParen,
165 Bytes: []byte{'('},
166 })
167 for index, arg := range args {
168 if index > 0 {
169 toks = append(toks, &Token{
170 Type: hclsyntax.TokenComma,
171 Bytes: []byte{','},
172 })
173 }
174 toks = append(toks, arg...)
175 }
176 toks = append(toks, &Token{
177 Type: hclsyntax.TokenCParen,
178 Bytes: []byte{')'},
179 })
180
181 format(toks) // fiddle with the SpacesBefore field to get canonical spacing
182 return toks
183}
184
185func appendTokensForValue(val cty.Value, toks Tokens) Tokens {
186 switch {

Callers 1

Calls 2

TokensForIdentifierFunction · 0.85
formatFunction · 0.85

Tested by 1