MCPcopy Create free account
hub / github.com/bufbuild/protocompile / fixupProtocSourceCodeInfo

Function fixupProtocSourceCodeInfo

sourceinfo/source_code_info_test.go:128–161  ·  view source on GitHub ↗
(info *descriptorpb.SourceCodeInfo)

Source from the content-addressed store, hash-verified

126}
127
128func fixupProtocSourceCodeInfo(info *descriptorpb.SourceCodeInfo) {
129 for i := 0; i < len(info.Location); i++ {
130 loc := info.Location[i]
131
132 pathStrs := make([]string, len(loc.Path))
133 for j, val := range loc.Path {
134 pathStrs[j] = strconv.FormatInt(int64(val), 10)
135 }
136 pathStr := strings.Join(pathStrs, ",")
137
138 for _, fixerEntry := range protocFixers {
139 match := false
140 for _, pattern := range fixerEntry.pathPatterns {
141 if pattern.MatchString(pathStr) {
142 match = true
143 break
144 }
145 }
146 if !match {
147 continue
148 }
149 newLoc := fixerEntry.fixer(info.Location, i)
150 if newLoc == nil {
151 // remove this entry
152 info.Location = append(info.Location[:i], info.Location[i+1:]...)
153 i--
154 } else {
155 info.Location[i] = newLoc
156 }
157 // only apply one fixer to each location
158 break
159 }
160 }
161}
162
163func TestSourceCodeInfoOptions(t *testing.T) {
164 t.Parallel()

Callers 1

TestSourceCodeInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…