7 "github.com/hashicorp/hcl2/hcl"
10 type navigation struct {
14 // Implementation of hcled.ContextString
15 func (n navigation) ContextString(offset int) string {
16 // We will walk our top-level blocks until we find one that contains
17 // the given offset, and then construct a representation of the header
21 for _, candidate := range n.root.Blocks {
22 if candidate.Range().ContainsOffset(offset) {
32 if len(block.Labels) == 0 {
37 buf := &bytes.Buffer{}
38 buf.WriteString(block.Type)
39 for _, label := range block.Labels {
40 fmt.Fprintf(buf, " %q", label)
45 func (n navigation) ContextDefRange(offset int) hcl.Range {
47 for _, candidate := range n.root.Blocks {
48 if candidate.Range().ContainsOffset(offset) {
58 return block.DefRange()