aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/hcl2/hcl/pos.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hcl/pos.go')
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/pos.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/pos.go b/vendor/github.com/hashicorp/hcl2/hcl/pos.go
index 1a4b329..06db8bf 100644
--- a/vendor/github.com/hashicorp/hcl2/hcl/pos.go
+++ b/vendor/github.com/hashicorp/hcl2/hcl/pos.go
@@ -31,6 +31,9 @@ type Pos struct {
31 Byte int 31 Byte int
32} 32}
33 33
34// InitialPos is a suitable position to use to mark the start of a file.
35var InitialPos = Pos{Byte: 0, Line: 1, Column: 1}
36
34// Range represents a span of characters between two positions in a source 37// Range represents a span of characters between two positions in a source
35// file. 38// file.
36// 39//
@@ -94,6 +97,16 @@ func RangeOver(a, b Range) Range {
94 } 97 }
95} 98}
96 99
100// ContainsPos returns true if and only if the given position is contained within
101// the receiving range.
102//
103// In the unlikely case that the line/column information disagree with the byte
104// offset information in the given position or receiving range, the byte
105// offsets are given priority.
106func (r Range) ContainsPos(pos Pos) bool {
107 return r.ContainsOffset(pos.Byte)
108}
109
97// ContainsOffset returns true if and only if the given byte offset is within 110// ContainsOffset returns true if and only if the given byte offset is within
98// the receiving Range. 111// the receiving Range.
99func (r Range) ContainsOffset(offset int) bool { 112func (r Range) ContainsOffset(offset int) bool {