(info *descriptorpb.SourceCodeInfo)
| 126 | } |
| 127 | |
| 128 | func 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 | |
| 163 | func TestSourceCodeInfoOptions(t *testing.T) { |
| 164 | t.Parallel() |
no outgoing calls
no test coverage detected
searching dependent graphs…