File tree Expand file tree Collapse file tree 4 files changed +48
-3
lines changed Expand file tree Collapse file tree 4 files changed +48
-3
lines changed Original file line number Diff line number Diff line change @@ -676,21 +676,30 @@ func (p *protoConverter) oneOf(x *proto.Oneof) {
676
676
677
677
p .addDecl (embed )
678
678
679
- for _ , v := range x . Elements {
680
- s : = & ast.StructLit {
679
+ newStruct := func () {
680
+ s = & ast.StructLit {
681
681
// TODO: make this the default in the formatter.
682
682
Rbrace : token .Newline .Pos (),
683
683
}
684
+ embed .Expr = ast .NewBinExpr (token .OR , embed .Expr , s )
685
+ }
686
+ for _ , v := range x .Elements {
684
687
switch x := v .(type ) {
685
688
case * proto.OneOfField :
689
+ newStruct ()
686
690
oneOf := p .parseField (s , 0 , x .Field )
687
691
oneOf .Optional = token .NoPos
688
692
693
+ case * proto.Comment :
694
+ cg := comment (x , false )
695
+ ast .SetRelPos (cg , token .NewSection )
696
+ s .Elts = append (s .Elts , cg )
697
+
689
698
default :
699
+ newStruct ()
690
700
p .messageField (s , 1 , v )
691
701
}
692
702
693
- embed .Expr = ast .NewBinExpr (token .OR , embed .Expr , s )
694
703
}
695
704
}
696
705
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ func TestExtractDefinitions(t *testing.T) {
38
38
"networking/v1alpha3/gateway.proto" ,
39
39
"mixer/v1/attributes.proto" ,
40
40
"mixer/v1/config/client/client_config.proto" ,
41
+ "other/trailcomment.proto" ,
41
42
}
42
43
for _ , file := range testCases {
43
44
t .Run (file , func (t * testing.T ) {
Original file line number Diff line number Diff line change
1
+ // Issue #586
2
+ package foo
3
+
4
+ message Bar {
5
+ oneof Foo {
6
+ string a = 1 ;
7
+ // hello world
8
+
9
+ string b = 2 ;
10
+ // hello world
11
+ }
12
+
13
+ int32 c = 3 ;
14
+ // hello world
15
+ }
Original file line number Diff line number Diff line change
1
+ // Issue #586
2
+ package foo
3
+
4
+ #Bar : {
5
+ {} | {
6
+ a : string @protobuf (1 )
7
+
8
+ // hello world
9
+
10
+ } | {
11
+ b : string @protobuf (2 )
12
+
13
+ // hello world
14
+
15
+ }
16
+ c ?: int32 @protobuf (3 )
17
+
18
+ // hello world
19
+
20
+ }
You can’t perform that action at this time.
0 commit comments