mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 01:26:43 +00:00
![Riley Karson](/assets/img/avatar_default.png)
```bash GO111MODULE=on go get github.com/hashicorp/terraform@pluginsdk-v0.12-early7 GO111MODULE=on go mod vendor GO111MODULE=on go mod tidy ```
35 lines
889 B
Go
35 lines
889 B
Go
package hcled
|
|
|
|
import (
|
|
"github.com/hashicorp/hcl2/hcl"
|
|
)
|
|
|
|
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.
|
|
func ContextString(file *hcl.File, offset int) string {
|
|
if cser, ok := file.Nav.(contextStringer); ok {
|
|
return cser.ContextString(offset)
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type contextDefRanger interface {
|
|
ContextDefRange(offset int) hcl.Range
|
|
}
|
|
|
|
func ContextDefRange(file *hcl.File, offset int) hcl.Range {
|
|
if cser, ok := file.Nav.(contextDefRanger); ok {
|
|
defRange := cser.ContextDefRange(offset)
|
|
if !defRange.Empty() {
|
|
return defRange
|
|
}
|
|
}
|
|
return file.Body.MissingItemRange()
|
|
}
|