summaryrefslogtreecommitdiff
path: root/hclsyntax/node.go
blob: 6ead6091c6ef7b3b596997d018f7bd38a32629d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

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)