github.com/hoveychen/protoreflect@v1.4.7-0.20221103114119-0b4b3385ec76/desc/protoprint/testfiles/test-preserve-comments.proto (about) 1 // This is the first detached comment for the syntax. 2 3 // This is a second detached comment. 4 5 // This is a third. 6 7 // Syntax comment... 8 syntax = "proto2"; // Syntax trailer. 9 10 // And now the package declaration 11 package foo.bar; 12 13 // option comments FTW!!! 14 option go_package = "github.com/hoveychen/protoreflect/internal/testprotos"; 15 16 import "google/protobuf/empty.proto"; 17 18 import "desc_test_options.proto"; 19 20 // Multiple white space lines (like above) cannot 21 // be preserved... 22 23 // We need a request for our RPC service below. 24 message /* detached message name */ /* request with a capital R */ Request /* trailer */ { 25 option deprecated = true; // deprecated! 26 27 // A field comment 28 repeated int32 ids = /* detached tag */ /* tag numero uno */ 1 /* 29 * tag trailer 30 * that spans multiple lines... 31 * more than two. 32 */ [packed = true /* packed! */, json_name = "|foo|" /* custom JSON! */, (testprotos.ffubar) = "abc", (testprotos.ffubarb) = "xyz"]; // field trailer #1... 33 34 // lead mfubar 35 option (testprotos.mfubar) = true; // trailing mfubar 36 37 // some detached comments 38 39 // some detached comments 40 41 // Another field comment 42 43 // label comment 44 optional /* type comment */ string /* name comment */ name = 2 [/* default lead */ default = "fubar" /* default trail */]; 45 46 extensions 100 to 200; 47 48 extensions 201 to 250 [(testprotos.exfubarb) = "\000\001\002\003\004\005\006\007", (testprotos.exfubar) = "splat!"]; 49 50 reserved 10 to 20, 30 to 50; 51 52 reserved "foo", "bar", "baz"; 53 54 // Group comment 55 optional group Extras = 3 { 56 // this is a custom option 57 option (testprotos.mfubar) = false; 58 59 optional double dbl = 1; 60 61 optional float flt = 2; 62 63 option no_standard_descriptor_accessor = false; 64 65 // Leading comment... 66 optional string str = 3; // Trailing comment... 67 } 68 69 enum MarioCharacters /* "super"! */ { 70 // allow_alias comments! 71 option allow_alias = true; 72 73 MARIO = 1 [(testprotos.evfubars) = -314, (testprotos.evfubar) = 278]; 74 75 LUIGI = 2 [(testprotos.evfubaruf) = 100, (testprotos.evfubaru) = 200]; 76 77 PEACH = 3; 78 79 BOWSER = 4; 80 81 option (testprotos.efubars) = -321; 82 83 WARIO = 5; 84 85 WALUIGI = 6; 86 87 SHY_GUY = 7 [(testprotos.evfubarsf) = 10101]; 88 89 HEY_HO = 7; 90 91 MAGIKOOPA = 8; 92 93 KAMEK = 8; 94 95 SNIFIT = -101; 96 97 option (testprotos.efubar) = 123; 98 } 99 100 // can be this or that 101 oneof abc { 102 string this = 4; 103 104 int32 that = 5; 105 } 106 107 108 // can be these or those 109 oneof xyz { 110 string these = 6; 111 112 int32 those = 7; 113 } 114 115 116 // map field 117 map<string, string> things = 8; 118 } 119 // And next we'll need some extensions... 120 121 extend /* extendee comment */ Request /* extendee trailer */ { 122 // comment for guid1 123 optional uint64 guid1 = 123; 124 125 // ... and a comment for guid2 126 optional uint64 guid2 = 124; 127 } 128 // extend trailer... 129 130 message /* name leading comment */ AnEmptyMessage /* name trailing comment */ { 131 } 132 133 // Service comment 134 service /* service name */ RpcService { 135 // option that sets field 136 option (testprotos.sfubar) = { id:100 name:"bob" }; 137 138 option deprecated = false; // DEPRECATED! 139 140 option (testprotos.sfubare) = VALUE; 141 142 // Method comment 143 rpc /* rpc name */ StreamingRpc /* comment A */ ( /* comment C */ stream Request ) returns ( /*comment E */ Request ); 144 145 rpc UnaryRpc ( Request ) returns ( google.protobuf.Empty ) { 146 option deprecated = true; 147 148 option (testprotos.mtfubar) = 12.340000; 149 150 option (testprotos.mtfubard) = 123.456000; 151 } 152 } 153 // service trailer