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

Method init

hclwrite/ast_attribute.go:25–47  ·  view source on GitHub ↗
(name string, expr *Expression)

Source from the content-addressed store, hash-verified

23}
24
25func (a *Attribute) init(name string, expr *Expression) {
26 expr.assertUnattached()
27
28 nameTok := newIdentToken(name)
29 nameObj := newIdentifier(nameTok)
30 a.leadComments = a.children.Append(newComments(nil))
31 a.name = a.children.Append(nameObj)
32 a.children.AppendUnstructuredTokens(Tokens{
33 {
34 Type: hclsyntax.TokenEqual,
35 Bytes: []byte{'='},
36 },
37 })
38 a.expr = a.children.Append(expr)
39 a.expr.list = a.children
40 a.lineComments = a.children.Append(newComments(nil))
41 a.children.AppendUnstructuredTokens(Tokens{
42 {
43 Type: hclsyntax.TokenNewline,
44 Bytes: []byte{'\n'},
45 },
46 })
47}
48
49func (a *Attribute) Expr() *Expression {
50 return a.expr.content.(*Expression)

Callers

nothing calls this directly

Calls 6

newIdentTokenFunction · 0.85
newIdentifierFunction · 0.85
newCommentsFunction · 0.85
assertUnattachedMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected