]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/hashicorp/hcl2/hcled/navigation.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / hcl2 / hcled / navigation.go
1 package hcled
2
3 import (
4 "github.com/hashicorp/hcl2/hcl"
5 )
6
7 type contextStringer interface {
8 ContextString(offset int) string
9 }
10
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)
18 }
19 return ""
20 }
21
22 type contextDefRanger interface {
23 ContextDefRange(offset int) hcl.Range
24 }
25
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() {
30 return defRange
31 }
32 }
33 return file.Body.MissingItemRange()
34 }