aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/hcl2/hclwrite/native_node_sorter.go
diff options
context:
space:
mode:
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.go23
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 @@
1package hclwrite
2
3import (
4 "github.com/hashicorp/hcl2/hcl/hclsyntax"
5)
6
7type nativeNodeSorter struct {
8 Nodes []hclsyntax.Node
9}
10
11func (s nativeNodeSorter) Len() int {
12 return len(s.Nodes)
13}
14
15func (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
21func (s nativeNodeSorter) Swap(i, j int) {
22 s.Nodes[i], s.Nodes[j] = s.Nodes[j], s.Nodes[i]
23}