mirror of
https://github.com/arkadiyt/protodump.git
synced 2026-10-21 17:56:51 +02:00
Handle proto3 optional fields
This commit is contained in:
1 parent
16270c3b99
commit
97fc40503e
5 files changed
+23
-19
No files matched your search
@@ -34,6 +34,7 @@ message HelloRequest {
|
||||
.hello.world.HelloRequest.Test blah = 2;
|
||||
.hello.world.HelloRequest.NestedEnum blahblah = 3;
|
||||
.hello.world.HelloReply blaha = 4;
|
||||
optional string version = 5;
|
||||
}
|
||||
|
||||
message HelloReply {
|
||||
|
||||
+13
-9
@@ -108,16 +108,20 @@ func (pd *ProtoDefinition) writeType(field protoreflect.FieldDescriptor) {
|
||||
|
||||
func (pd *ProtoDefinition) writeOneof(oneof protoreflect.OneofDescriptor) {
|
||||
// TODO need to handle oneof options
|
||||
pd.writeIndented("")
|
||||
pd.write("oneof ")
|
||||
pd.write(string(oneof.Name()))
|
||||
pd.write(" {\n")
|
||||
pd.indent()
|
||||
for i := 0; i < oneof.Fields().Len(); i++ {
|
||||
pd.writeField(oneof.Fields().Get(i))
|
||||
if oneof.IsSynthetic() {
|
||||
pd.writeField(oneof.Fields().Get(0))
|
||||
} else {
|
||||
pd.writeIndented("")
|
||||
pd.write("oneof ")
|
||||
pd.write(string(oneof.Name()))
|
||||
pd.write(" {\n")
|
||||
pd.indent()
|
||||
for i := 0; i < oneof.Fields().Len(); i++ {
|
||||
pd.writeField(oneof.Fields().Get(i))
|
||||
}
|
||||
pd.dedent()
|
||||
pd.writeIndented("}\n")
|
||||
}
|
||||
pd.dedent()
|
||||
pd.writeIndented("}\n")
|
||||
}
|
||||
|
||||
func (pd *ProtoDefinition) writeField(field protoreflect.FieldDescriptor) {
|
||||
|
||||
Reference in new issue
Block a user