MergePosition returns the union of two positions such that the result contains both inputs.
(a, b *Position)
| 28 | |
| 29 | // MergePosition returns the union of two positions such that the result contains both inputs. |
| 30 | func Merge(a, b *Position) *Position { |
| 31 | if a == nil { |
| 32 | return b |
| 33 | } |
| 34 | if b == nil { |
| 35 | return a |
| 36 | } |
| 37 | if a.Filename != b.Filename { |
| 38 | return a |
| 39 | } |
| 40 | // TODO(jaq): handle multi-line positions |
| 41 | if a.Line != b.Line { |
| 42 | return a |
| 43 | } |
| 44 | r := *a |
| 45 | if b.Startcol < r.Startcol { |
| 46 | r.Startcol = b.Startcol |
| 47 | } |
| 48 | if b.Endcol > r.Endcol { |
| 49 | r.Endcol = b.Endcol |
| 50 | } |
| 51 | return &r |
| 52 | } |
no outgoing calls
no test coverage detected