4 "github.com/hashicorp/hcl2/hcl"
7 type contextStringer interface {
8 ContextString(offset int) string
11 // ContextString returns a string describing the context of the given byte
12 // offset, if available. An empty string is returned if no such information
13 // is available, or otherwise the returned string is in a form that depends
14 // on the language used to write the referenced file.
15 func ContextString(file *hcl.File, offset int) string {
16 if cser, ok := file.Nav.(contextStringer); ok {
17 return cser.ContextString(offset)
22 type contextDefRanger interface {
23 ContextDefRange(offset int) hcl.Range
26 func ContextDefRange(file *hcl.File, offset int) hcl.Range {
27 if cser, ok := file.Nav.(contextDefRanger); ok {
28 defRange := cser.ContextDefRange(offset)
29 if !defRange.Empty() {
33 return file.Body.MissingItemRange()