Jelajahi Sumber

protoc-gen-go: Add Filename to ExtensionDesc.

This will allow looking up the FileDescriptorProto for the file that
defines an extension of a message, for richer introspection.
Googler 9 tahun lalu
induk
melakukan
24f28ae800
2 mengubah file dengan 2 tambahan dan 0 penghapusan
  1. 1 0
      proto/extensions.go
  2. 1 0
      protoc-gen-go/generator/generator.go

+ 1 - 0
proto/extensions.go

@@ -154,6 +154,7 @@ type ExtensionDesc struct {
 	Field         int32       // field number
 	Name          string      // fully-qualified name of extension, for text formatting
 	Tag           string      // protobuf tag style
+	Filename      string      // name of the file in which the extension is defined
 }
 
 func (ed *ExtensionDesc) repeated() bool {

+ 1 - 0
protoc-gen-go/generator/generator.go

@@ -2556,6 +2556,7 @@ func (g *Generator) generateExtension(ext *ExtensionDescriptor) {
 	g.P("Field: ", field.Number, ",")
 	g.P(`Name: "`, extName, `",`)
 	g.P("Tag: ", tag, ",")
+	g.P(`Filename: "`, g.file.GetName(), `",`)
 
 	g.Out()
 	g.P("}")