First keep in mind that some comments are detached and thus ignored by SourceCodeInfo.
That being said, IIRC I've seen a very hacky way to achieve similar goals: https://github.com/protocolbuffers/protobuf/blob/3322c0b92a5001ade92608d75891d63c749d624d/src/google/protobuf/compiler/parser_unittest.cc#L2472 On Thursday, September 1, 2022 at 7:16:52 AM UTC-7 [email protected] wrote: > I'm parsing a large number of protobuf files and am using the Source Code > Info descriptor to extract comment data from the source files as well. I > currently use the FileDescriptorProto.ListFields() method to extract the > DescriptorProto objects I care about as well as the SourceCodeInfo. > > To my knowledge, the only way to pair up Location fields with the > corresponding objects is via the path attribute > <https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor.pb>. > > This is fine; except for the fact that involves me manually stepping > through said path to land at my parsed Protobuf Object. This gets > complicated when dealing with layers of nested_types and I am convinced > there must be a way for me to extract the path from the particular > DescriptorProto Object and then use that to match up the object with the > path specified in the corresponding Location field. > > In short: How can I easily pair up DescriptorProto objects with the > Location objects that correspond to them? Specifically for comment parsing > purposes. > -- 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/13fbfaad-dd54-48af-85b8-046d40f6327cn%40googlegroups.com.
