]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/hashicorp/hcl2/hclwrite/ast_attribute.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / hcl2 / hclwrite / ast_attribute.go
1 package hclwrite
2
3 import (
4 "github.com/hashicorp/hcl2/hcl/hclsyntax"
5 )
6
7 type Attribute struct {
8 inTree
9
10 leadComments *node
11 name *node
12 expr *node
13 lineComments *node
14 }
15
16 func newAttribute() *Attribute {
17 return &Attribute{
18 inTree: newInTree(),
19 }
20 }
21
22 func (a *Attribute) init(name string, expr *Expression) {
23 expr.assertUnattached()
24
25 nameTok := newIdentToken(name)
26 nameObj := newIdentifier(nameTok)
27 a.leadComments = a.children.Append(newComments(nil))
28 a.name = a.children.Append(nameObj)
29 a.children.AppendUnstructuredTokens(Tokens{
30 {
31 Type: hclsyntax.TokenEqual,
32 Bytes: []byte{'='},
33 },
34 })
35 a.expr = a.children.Append(expr)
36 a.expr.list = a.children
37 a.lineComments = a.children.Append(newComments(nil))
38 a.children.AppendUnstructuredTokens(Tokens{
39 {
40 Type: hclsyntax.TokenNewline,
41 Bytes: []byte{'\n'},
42 },
43 })
44 }
45
46 func (a *Attribute) Expr() *Expression {
47 return a.expr.content.(*Expression)
48 }