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

Method init

hclwrite/ast_block.go:35–64  ·  view source on GitHub ↗
(typeName string, labels []string)

Source from the content-addressed store, hash-verified

33}
34
35func (b *Block) init(typeName string, labels []string) {
36 nameTok := newIdentToken(typeName)
37 nameObj := newIdentifier(nameTok)
38 b.leadComments = b.children.Append(newComments(nil))
39 b.typeName = b.children.Append(nameObj)
40 labelsObj := newBlockLabels(labels)
41 b.labels = b.children.Append(labelsObj)
42 b.open = b.children.AppendUnstructuredTokens(Tokens{
43 {
44 Type: hclsyntax.TokenOBrace,
45 Bytes: []byte{'{'},
46 },
47 {
48 Type: hclsyntax.TokenNewline,
49 Bytes: []byte{'\n'},
50 },
51 })
52 body := newBody() // initially totally empty; caller can append to it subsequently
53 b.body = b.children.Append(body)
54 b.close = b.children.AppendUnstructuredTokens(Tokens{
55 {
56 Type: hclsyntax.TokenCBrace,
57 Bytes: []byte{'}'},
58 },
59 {
60 Type: hclsyntax.TokenNewline,
61 Bytes: []byte{'\n'},
62 },
63 })
64}
65
66// Body returns the body that represents the content of the receiving block.
67//

Callers 5

NewBlockFunction · 0.45
SetAttributeRawMethod · 0.45
SetAttributeValueMethod · 0.45
SetAttributeTraversalMethod · 0.45
AppendNewBlockMethod · 0.45

Calls 7

newIdentTokenFunction · 0.85
newIdentifierFunction · 0.85
newCommentsFunction · 0.85
newBlockLabelsFunction · 0.85
newBodyFunction · 0.85
AppendMethod · 0.45

Tested by

no test coverage detected