diff options
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hcl/json/ast.go')
-rw-r--r-- | vendor/github.com/hashicorp/hcl2/hcl/json/ast.go | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/json/ast.go b/vendor/github.com/hashicorp/hcl2/hcl/json/ast.go new file mode 100644 index 0000000..753bfa0 --- /dev/null +++ b/vendor/github.com/hashicorp/hcl2/hcl/json/ast.go | |||
@@ -0,0 +1,121 @@ | |||
1 | package json | ||
2 | |||
3 | import ( | ||
4 | "math/big" | ||
5 | |||
6 | "github.com/hashicorp/hcl2/hcl" | ||
7 | ) | ||
8 | |||
9 | type node interface { | ||
10 | Range() hcl.Range | ||
11 | StartRange() hcl.Range | ||
12 | } | ||
13 | |||
14 | type objectVal struct { | ||
15 | Attrs []*objectAttr | ||
16 | SrcRange hcl.Range // range of the entire object, brace-to-brace | ||
17 | OpenRange hcl.Range // range of the opening brace | ||
18 | CloseRange hcl.Range // range of the closing brace | ||
19 | } | ||
20 | |||
21 | func (n *objectVal) Range() hcl.Range { | ||
22 | return n.SrcRange | ||
23 | } | ||
24 | |||
25 | func (n *objectVal) StartRange() hcl.Range { | ||
26 | return n.OpenRange | ||
27 | } | ||
28 | |||
29 | type objectAttr struct { | ||
30 | Name string | ||
31 | Value node | ||
32 | NameRange hcl.Range // range of the name string | ||
33 | } | ||
34 | |||
35 | func (n *objectAttr) Range() hcl.Range { | ||
36 | return n.NameRange | ||
37 | } | ||
38 | |||
39 | func (n *objectAttr) StartRange() hcl.Range { | ||
40 | return n.NameRange | ||
41 | } | ||
42 | |||
43 | type arrayVal struct { | ||
44 | Values []node | ||
45 | SrcRange hcl.Range // range of the entire object, bracket-to-bracket | ||
46 | OpenRange hcl.Range // range of the opening bracket | ||
47 | } | ||
48 | |||
49 | func (n *arrayVal) Range() hcl.Range { | ||
50 | return n.SrcRange | ||
51 | } | ||
52 | |||
53 | func (n *arrayVal) StartRange() hcl.Range { | ||
54 | return n.OpenRange | ||
55 | } | ||
56 | |||
57 | type booleanVal struct { | ||
58 | Value bool | ||
59 | SrcRange hcl.Range | ||
60 | } | ||
61 | |||
62 | func (n *booleanVal) Range() hcl.Range { | ||
63 | return n.SrcRange | ||
64 | } | ||
65 | |||
66 | func (n *booleanVal) StartRange() hcl.Range { | ||
67 | return n.SrcRange | ||
68 | } | ||
69 | |||
70 | type numberVal struct { | ||
71 | Value *big.Float | ||
72 | SrcRange hcl.Range | ||
73 | } | ||
74 | |||
75 | func (n *numberVal) Range() hcl.Range { | ||
76 | return n.SrcRange | ||
77 | } | ||
78 | |||
79 | func (n *numberVal) StartRange() hcl.Range { | ||
80 | return n.SrcRange | ||
81 | } | ||
82 | |||
83 | type stringVal struct { | ||
84 | Value string | ||
85 | SrcRange hcl.Range | ||
86 | } | ||
87 | |||
88 | func (n *stringVal) Range() hcl.Range { | ||
89 | return n.SrcRange | ||
90 | } | ||
91 | |||
92 | func (n *stringVal) StartRange() hcl.Range { | ||
93 | return n.SrcRange | ||
94 | } | ||
95 | |||
96 | type nullVal struct { | ||
97 | SrcRange hcl.Range | ||
98 | } | ||
99 | |||
100 | func (n *nullVal) Range() hcl.Range { | ||
101 | return n.SrcRange | ||
102 | } | ||
103 | |||
104 | func (n *nullVal) StartRange() hcl.Range { | ||
105 | return n.SrcRange | ||
106 | } | ||
107 | |||
108 | // invalidVal is used as a placeholder where a value is needed for a valid | ||
109 | // parse tree but the input was invalid enough to prevent one from being | ||
110 | // created. | ||
111 | type invalidVal struct { | ||
112 | SrcRange hcl.Range | ||
113 | } | ||
114 | |||
115 | func (n invalidVal) Range() hcl.Range { | ||
116 | return n.SrcRange | ||
117 | } | ||
118 | |||
119 | func (n invalidVal) StartRange() hcl.Range { | ||
120 | return n.SrcRange | ||
121 | } | ||