Skip to content

Is there an easy way to get the location of a descriptor(message、field, etc.)? #1295

@ououmania

Description

@ououmania

Please forgive me if the answer seems obvious. But I do need help to find an easy way to ge the source location of the protobuf
descriptors. I did read the part in the document but it's really not easy to parse these mysterious numbers to find the location.
Is there already some helper method to bind the path to a descriptor?

Each element is a field number or an index. They form a path from the root FileDescriptorProto to the 
place where the definition. 
For example, this path: [ 4, 3, 2, 7, 1 ] refers to: file.message_type(3) // 4, 3 .field(7) // 2, 7 .name() // 1 
This is because FileDescriptorProto.message_type has field number 4: repeated DescriptorProto message_type = 4; 
and DescriptorProto.field has field number 2: repeated FieldDescriptorProto field = 2; and 
FieldDescriptorProto.name has field number 1: optional string name = 1;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions