]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/navigation.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / hcl2 / hcl / hclsyntax / navigation.go
index 4d41b6b6624f4bbcc5e80682672c1b49e7d6668b..c8c97f37cdc81fded382e8940ca17fd1e3ffb920 100644 (file)
@@ -3,6 +3,8 @@ package hclsyntax
 import (
        "bytes"
        "fmt"
+
+       "github.com/hashicorp/hcl2/hcl"
 )
 
 type navigation struct {
@@ -39,3 +41,19 @@ func (n navigation) ContextString(offset int) string {
        }
        return buf.String()
 }
+
+func (n navigation) ContextDefRange(offset int) hcl.Range {
+       var block *Block
+       for _, candidate := range n.root.Blocks {
+               if candidate.Range().ContainsOffset(offset) {
+                       block = candidate
+                       break
+               }
+       }
+
+       if block == nil {
+               return hcl.Range{}
+       }
+
+       return block.DefRange()
+}