reflect/protoreflect: add FileDescriptor.SourceLocations
This adds minimal support for preserving the source context information.
Change-Id: I4b3cac9690b7469ecb4e5434251a809be4d7894c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/183157
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/reflect/protodesc/file_test.go b/reflect/protodesc/file_test.go
index dd6dde6..9de1d03 100644
--- a/reflect/protodesc/file_test.go
+++ b/reflect/protodesc/file_test.go
@@ -181,6 +181,33 @@
`),
// TODO: Test import public
}, {
+ label: "preserve source code locations",
+ inDesc: mustParseFile(`
+ name: "test.proto"
+ package: "fizz.buzz"
+ source_code_info: {location: [{
+ span: [39,0,882,1]
+ }, {
+ path: [12]
+ span: [39,0,18]
+ leading_detached_comments: [" foo\n"," bar\n"]
+ }, {
+ path: [8,9]
+ span: [51,0,28]
+ leading_comments: " Comment\n"
+ }]}
+ `),
+ }, {
+ label: "invalid source code span",
+ inDesc: mustParseFile(`
+ name: "test.proto"
+ package: "fizz.buzz"
+ source_code_info: {location: [{
+ span: [39]
+ }]}
+ `),
+ wantErr: `invalid span: [39]`,
+ }, {
label: "resolve relative reference",
inDesc: mustParseFile(`
name: "test.proto"