summaryrefslogtreecommitdiff
path: root/hclsyntax/node.go
diff options
context:
space:
mode:
authorMartin Atkins <mart@degeneration.co.uk>2019-09-09 16:08:19 -0700
committerMartin Atkins <mart@degeneration.co.uk>2019-09-09 16:08:19 -0700
commit6c4344623b6ac528a57f9b80e4622acfab2fde40 (patch)
tree83031084d3ab54abbe40e3fd749e439c8b28e9d1 /hclsyntax/node.go
parent0f5ab3bd563c111077917020c0cbc8c211e1bff3 (diff)
Unfold the "hcl" directory up into the root
The main HCL package is more visible this way, and so it's easier than having to pick it out from dozens of other package directories.
Diffstat (limited to 'hclsyntax/node.go')
-rw-r--r--hclsyntax/node.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/hclsyntax/node.go b/hclsyntax/node.go
new file mode 100644
index 0000000..41b35e5
--- /dev/null
+++ b/hclsyntax/node.go
@@ -0,0 +1,22 @@
+package hclsyntax
+
+import (
+ "github.com/hashicorp/hcl/v2"
+)
+
+// Node is the abstract type that every AST node implements.
+//
+// This is a closed interface, so it cannot be implemented from outside of
+// this package.
+type Node interface {
+ // This is the mechanism by which the public-facing walk functions
+ // are implemented. Implementations should call the given function
+ // for each child node and then replace that node with its return value.
+ // The return value might just be the same node, for non-transforming
+ // walks.
+ walkChildNodes(w internalWalkFunc)
+
+ Range() hcl.Range
+}
+
+type internalWalkFunc func(Node)