2017-09-11 16:00:31 -07:00
|
|
|
package hcled
|
2017-05-19 18:56:39 -07:00
|
|
|
|
|
|
|
import (
|
2017-09-11 16:40:37 -07:00
|
|
|
"github.com/hashicorp/hcl2/hcl"
|
2017-05-19 18:56:39 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
type contextStringer interface {
|
|
|
|
ContextString(offset int) string
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContextString returns a string describing the context of the given byte
|
|
|
|
// offset, if available. An empty string is returned if no such information
|
|
|
|
// is available, or otherwise the returned string is in a form that depends
|
|
|
|
// on the language used to write the referenced file.
|
2017-09-11 16:40:37 -07:00
|
|
|
func ContextString(file *hcl.File, offset int) string {
|
2017-05-19 18:56:39 -07:00
|
|
|
if cser, ok := file.Nav.(contextStringer); ok {
|
|
|
|
return cser.ContextString(offset)
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|