hcl/ext/include/resolver.go
Martin Atkins 708abb8c97 Move the zcl package and its two parsing subpackages to "hcl" names
This is a super-invasive update since the "zcl" package in particular
is referenced all over.

There are probably still a few zcl references hanging around in comments,
etc but this takes care of most of it.
2017-09-11 16:40:37 -07:00

29 lines
1008 B
Go

package include
import (
"github.com/hashicorp/hcl2/hcl"
)
// A Resolver maps an include path (an arbitrary string, but usually something
// filepath-like) to a hcl.Body.
//
// The parameter "refRange" is the source range of the expression in the calling
// body that provided the given path, for use in generating "invalid path"-type
// diagnostics.
//
// If the returned body is nil, it will be ignored.
//
// Any returned diagnostics will be emitted when content is requested from the
// final composed body (after all includes have been dealt with).
type Resolver interface {
ResolveBodyPath(path string, refRange hcl.Range) (hcl.Body, hcl.Diagnostics)
}
// ResolverFunc is a function type that implements Resolver.
type ResolverFunc func(path string, refRange hcl.Range) (hcl.Body, hcl.Diagnostics)
// ResolveBodyPath is an implementation of Resolver.ResolveBodyPath.
func (f ResolverFunc) ResolveBodyPath(path string, refRange hcl.Range) (hcl.Body, hcl.Diagnostics) {
return f(path, refRange)
}