MCPcopy
hub / github.com/hashicorp/hcl / Overlaps

Method Overlaps

pos.go:200–215  ·  view source on GitHub ↗

Overlaps returns true if the receiver and the other given range share any characters in common.

(other Range)

Source from the content-addressed store, hash-verified

198// Overlaps returns true if the receiver and the other given range share any
199// characters in common.
200func (r Range) Overlaps(other Range) bool {
201 switch {
202 case r.Filename != other.Filename:
203 // If the ranges are in different files then they can't possibly overlap
204 return false
205 case r.Empty() || other.Empty():
206 // Empty ranges can never overlap
207 return false
208 case r.ContainsOffset(other.Start.Byte) || r.ContainsOffset(other.End.Byte):
209 return true
210 case other.ContainsOffset(r.Start.Byte) || other.ContainsOffset(r.End.Byte):
211 return true
212 default:
213 return false
214 }
215}
216
217// Overlap finds a range that is either identical to or a sub-range of both
218// the receiver and the other given range. It returns an empty range

Callers 2

OverlapMethod · 0.95
WriteDiagnosticMethod · 0.80

Calls 2

EmptyMethod · 0.95
ContainsOffsetMethod · 0.95

Tested by

no test coverage detected