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

Function appendTokensForTraversalStep

hclwrite/generate.go:314–348  ·  view source on GitHub ↗
(step hcl.Traverser, toks Tokens)

Source from the content-addressed store, hash-verified

312}
313
314func appendTokensForTraversalStep(step hcl.Traverser, toks Tokens) Tokens {
315 switch ts := step.(type) {
316 case hcl.TraverseRoot:
317 toks = append(toks, &Token{
318 Type: hclsyntax.TokenIdent,
319 Bytes: []byte(ts.Name),
320 })
321 case hcl.TraverseAttr:
322 toks = append(
323 toks,
324 &Token{
325 Type: hclsyntax.TokenDot,
326 Bytes: []byte{'.'},
327 },
328 &Token{
329 Type: hclsyntax.TokenIdent,
330 Bytes: []byte(ts.Name),
331 },
332 )
333 case hcl.TraverseIndex:
334 toks = append(toks, &Token{
335 Type: hclsyntax.TokenOBrack,
336 Bytes: []byte{'['},
337 })
338 toks = appendTokensForValue(ts.Key, toks)
339 toks = append(toks, &Token{
340 Type: hclsyntax.TokenCBrack,
341 Bytes: []byte{']'},
342 })
343 default:
344 panic(fmt.Sprintf("unsupported traversal step type %T", step))
345 }
346
347 return toks
348}
349
350func escapeQuotedStringLit(s string) []byte {
351 if len(s) == 0 {

Callers 1

appendTokensForTraversalFunction · 0.85

Calls 1

appendTokensForValueFunction · 0.85

Tested by

no test coverage detected