MCPcopy
hub / github.com/google/mtail / Merge

Function Merge

internal/runtime/compiler/position/position.go:30–52  ·  view source on GitHub ↗

MergePosition returns the union of two positions such that the result contains both inputs.

(a, b *Position)

Source from the content-addressed store, hash-verified

28
29// MergePosition returns the union of two positions such that the result contains both inputs.
30func 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}

Callers 8

positionFromMarkFunction · 0.92
PosMethod · 0.92
PosMethod · 0.92
PosMethod · 0.92
PosMethod · 0.92
PosMethod · 0.92
mergepositionlistFunction · 0.92
VisitAfterMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected