(opts OptionIndex, sci *sourceCodeInfo, n ast.MessageDeclNode, fieldPath []int32, path []int32)
| 307 | } |
| 308 | |
| 309 | func generateSourceCodeInfoForMessage(opts OptionIndex, sci *sourceCodeInfo, n ast.MessageDeclNode, fieldPath []int32, path []int32) { |
| 310 | var openBrace ast.Node |
| 311 | |
| 312 | var decls []ast.MessageElement |
| 313 | switch n := n.(type) { |
| 314 | case *ast.MessageNode: |
| 315 | openBrace = n.OpenBrace |
| 316 | decls = n.Decls |
| 317 | case *ast.SyntheticGroupMessageNode: |
| 318 | openBrace = n.OpenBrace |
| 319 | decls = n.Decls |
| 320 | case *ast.SyntheticMapEntryNode: |
| 321 | sci.newLoc(n, path) |
| 322 | // map entry so nothing else to do |
| 323 | return |
| 324 | } |
| 325 | sci.newBlockLocWithComments(n, openBrace, path) |
| 326 | |
| 327 | sci.newLoc(n.MessageName(), append(path, internal.MessageNameTag)) |
| 328 | // matching protoc, which emits the corresponding field type name (for group fields) |
| 329 | // right after the source location for the group message name |
| 330 | if fieldPath != nil { |
| 331 | sci.newLoc(n.MessageName(), append(fieldPath, internal.FieldTypeNameTag)) |
| 332 | } |
| 333 | |
| 334 | var optIndex, fieldIndex, oneofIndex, extendIndex, nestedMsgIndex int32 |
| 335 | var nestedEnumIndex, extRangeIndex, reservedRangeIndex, reservedNameIndex int32 |
| 336 | for _, child := range decls { |
| 337 | switch child := child.(type) { |
| 338 | case *ast.OptionNode: |
| 339 | generateSourceCodeInfoForOption(opts, sci, child, false, &optIndex, append(path, internal.MessageOptionsTag)) |
| 340 | case *ast.FieldNode: |
| 341 | generateSourceCodeInfoForField(opts, sci, child, append(path, internal.MessageFieldsTag, fieldIndex)) |
| 342 | fieldIndex++ |
| 343 | case *ast.GroupNode: |
| 344 | fldPath := append(path, internal.MessageFieldsTag, fieldIndex) //nolint:gocritic // intentionally creating new slice var |
| 345 | generateSourceCodeInfoForField(opts, sci, child, fldPath) |
| 346 | fieldIndex++ |
| 347 | // we clone the path here so that append can't mutate fldPath, since they may share storage |
| 348 | msgPath := append(internal.ClonePath(path), internal.MessageNestedMessagesTag, nestedMsgIndex) |
| 349 | generateSourceCodeInfoForMessage(opts, sci, child.AsMessage(), fldPath, msgPath) |
| 350 | nestedMsgIndex++ |
| 351 | case *ast.MapFieldNode: |
| 352 | generateSourceCodeInfoForField(opts, sci, child, append(path, internal.MessageFieldsTag, fieldIndex)) |
| 353 | fieldIndex++ |
| 354 | nestedMsgIndex++ |
| 355 | case *ast.OneofNode: |
| 356 | fldsPath := append(path, internal.MessageFieldsTag) //nolint:gocritic // intentionally creating new slice var |
| 357 | // we clone the path here and below so that append ops can't mutate |
| 358 | // fldPath or msgsPath, since they may otherwise share storage |
| 359 | msgsPath := append(internal.ClonePath(path), internal.MessageNestedMessagesTag) |
| 360 | ooPath := append(internal.ClonePath(path), internal.MessageOneofsTag, oneofIndex) |
| 361 | generateSourceCodeInfoForOneof(opts, sci, child, &fieldIndex, &nestedMsgIndex, fldsPath, msgsPath, ooPath) |
| 362 | oneofIndex++ |
| 363 | case *ast.MessageNode: |
| 364 | generateSourceCodeInfoForMessage(opts, sci, child, nil, append(path, internal.MessageNestedMessagesTag, nestedMsgIndex)) |
| 365 | nestedMsgIndex++ |
| 366 | case *ast.EnumNode: |
no test coverage detected
searching dependent graphs…