diff options
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/navigation.go')
-rw-r--r-- | vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/navigation.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/navigation.go b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/navigation.go index 4d41b6b..c8c97f3 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/navigation.go +++ b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/navigation.go | |||
@@ -3,6 +3,8 @@ package hclsyntax | |||
3 | import ( | 3 | import ( |
4 | "bytes" | 4 | "bytes" |
5 | "fmt" | 5 | "fmt" |
6 | |||
7 | "github.com/hashicorp/hcl2/hcl" | ||
6 | ) | 8 | ) |
7 | 9 | ||
8 | type navigation struct { | 10 | type navigation struct { |
@@ -39,3 +41,19 @@ func (n navigation) ContextString(offset int) string { | |||
39 | } | 41 | } |
40 | return buf.String() | 42 | return buf.String() |
41 | } | 43 | } |
44 | |||
45 | func (n navigation) ContextDefRange(offset int) hcl.Range { | ||
46 | var block *Block | ||
47 | for _, candidate := range n.root.Blocks { | ||
48 | if candidate.Range().ContainsOffset(offset) { | ||
49 | block = candidate | ||
50 | break | ||
51 | } | ||
52 | } | ||
53 | |||
54 | if block == nil { | ||
55 | return hcl.Range{} | ||
56 | } | ||
57 | |||
58 | return block.DefRange() | ||
59 | } | ||