diff options
author | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
---|---|---|
committer | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
commit | 107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch) | |
tree | ca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/hashicorp/hcl2/hclwrite/native_node_sorter.go | |
parent | 844b5a68d8af4791755b8f0ad293cc99f5959183 (diff) | |
download | terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip |
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hclwrite/native_node_sorter.go')
-rw-r--r-- | vendor/github.com/hashicorp/hcl2/hclwrite/native_node_sorter.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hclwrite/native_node_sorter.go b/vendor/github.com/hashicorp/hcl2/hclwrite/native_node_sorter.go new file mode 100644 index 0000000..a13c0ec --- /dev/null +++ b/vendor/github.com/hashicorp/hcl2/hclwrite/native_node_sorter.go | |||
@@ -0,0 +1,23 @@ | |||
1 | package hclwrite | ||
2 | |||
3 | import ( | ||
4 | "github.com/hashicorp/hcl2/hcl/hclsyntax" | ||
5 | ) | ||
6 | |||
7 | type nativeNodeSorter struct { | ||
8 | Nodes []hclsyntax.Node | ||
9 | } | ||
10 | |||
11 | func (s nativeNodeSorter) Len() int { | ||
12 | return len(s.Nodes) | ||
13 | } | ||
14 | |||
15 | func (s nativeNodeSorter) Less(i, j int) bool { | ||
16 | rangeI := s.Nodes[i].Range() | ||
17 | rangeJ := s.Nodes[j].Range() | ||
18 | return rangeI.Start.Byte < rangeJ.Start.Byte | ||
19 | } | ||
20 | |||
21 | func (s nativeNodeSorter) Swap(i, j int) { | ||
22 | s.Nodes[i], s.Nodes[j] = s.Nodes[j], s.Nodes[i] | ||
23 | } | ||