Also to be complete, I use the following command to turn the proto file
into a desc file:
protoc --include_source_info --descriptor_set_out=test.desc enum.proto
and then to have a human readable format, I run:
cat test.desc | protoc --decode=google.protobuf.FileDescriptorSet
-I/usr/local/include/google/protobuf
/usr/local/include/google/protobuf/descriptor.proto
finally, protoc --version returns:
libprotoc 23.1
On Tuesday, May 23, 2023 at 8:59:21 AM UTC+8 Clément Jean wrote:
> I'm working a parser for Protobuf and recently I am working with
> SourceLocationInfo.
> I've been noticing something weird when using options. However, I'm not
> sure if my understanding is not complete or if its a bug.
>
> I have the following enum:
>
> enum Test {
> option deprecated = true;
>
> TEST_UNSPECIFIED = 0;
> }
>
> And I get the following FileDescriptorSet (simplified):
>
> file {
> ...
> source_code_info {
> location {
> span: 0
> span: 0
> span: 4
> span: 1
> }
> location {
> path: 5
> path: 0
> span: 0
> span: 0
> span: 4
> span: 1
> }
> location {
> path: 5
> path: 0
> path: 1
> span: 0
> span: 5
> span: 9
> }
> location {
> path: 5
> path: 0
> path: 3
> span: 1
> span: 8
> span: 33
> }
> location {
> path: 5
> path: 0
> path: 3
> path: 3
> span: 1
> span: 8
> span: 33
> }
> location {
> path: 5
> path: 0
> path: 2
> path: 0
> span: 3
> span: 8
> span: 29
> }
> location {
> path: 5
> path: 0
> path: 2
> path: 0
> path: 1
> span: 3
> span: 8
> span: 24
> }
> location {
> path: 5
> path: 0
> path: 2
> path: 0
> path: 2
> span: 3
> span: 27
> span: 28
> }
> }
> }
>
> I'm confused by the ones I wrote in red. These doesn't seem to be correct.
> An example is span: 1 span: 8 span: 33. To the best of my knowledge, this
> means
> that we have an element at line 1 (2 in an IDE) column 8 (9 in IDE) that
> finishes on the same line (third span omitted) and at column 33. However,
> the option line is only 27 characters long...
>
> Is my mental model about SourceCodeInfo wrong? Or is it a bug?
>
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/protobuf/a2ce2413-325d-4609-9150-804baa16d177n%40googlegroups.com.