Overlaps returns true if the receiver and the other given range share any characters in common.
(other Range)
| 198 | // Overlaps returns true if the receiver and the other given range share any |
| 199 | // characters in common. |
| 200 | func (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 |
no test coverage detected