source.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2019 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package protoreflect
  5. // SourceLocations is a list of source locations.
  6. type SourceLocations interface {
  7. // Len reports the number of source locations in the proto file.
  8. Len() int
  9. // Get returns the ith SourceLocation. It panics if out of bounds.
  10. Get(int) SourceLocation
  11. doNotImplement
  12. // TODO: Add ByPath and ByDescriptor helper methods.
  13. }
  14. // SourceLocation describes a source location and
  15. // corresponds with the google.protobuf.SourceCodeInfo.Location message.
  16. type SourceLocation struct {
  17. // Path is the path to the declaration from the root file descriptor.
  18. // The contents of this slice must not be mutated.
  19. Path SourcePath
  20. // StartLine and StartColumn are the zero-indexed starting location
  21. // in the source file for the declaration.
  22. StartLine, StartColumn int
  23. // EndLine and EndColumn are the zero-indexed ending location
  24. // in the source file for the declaration.
  25. // In the descriptor.proto, the end line may be omitted if it is identical
  26. // to the start line. Here, it is always populated.
  27. EndLine, EndColumn int
  28. // LeadingDetachedComments are the leading detached comments
  29. // for the declaration. The contents of this slice must not be mutated.
  30. LeadingDetachedComments []string
  31. // LeadingComments is the leading attached comment for the declaration.
  32. LeadingComments string
  33. // TrailingComments is the trailing attached comment for the declaration.
  34. TrailingComments string
  35. }
  36. // SourcePath identifies a part of a file descriptor for a source location.
  37. // The SourcePath is a sequence of either field numbers or indexes into
  38. // a repeated field that form a path starting from the root file descriptor.
  39. //
  40. // See google.protobuf.SourceCodeInfo.Location.path.
  41. type SourcePath []int32
  42. // TODO: Add SourcePath.String method to pretty-print the path. For example:
  43. // ".message_type[6].nested_type[15].field[3]"