github.com/Big-big-orange/protoreflect@v0.0.0-20240408141420-285cedfdf6a4/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/Big-big-orange/protoreflect/internal/testprotos"; 15 16 import public "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 /* request with a capital R */ Request /* trailer */ { 25 option deprecated = true; // deprecated! 26 27 // A field comment 28 repeated int32 ids = /* tag numero uno */ 1 /* 29 * tag trailer 30 * that spans multiple lines... 31 * more than two. 32 */ [ 33 packed = true, 34 // packed! 35 json_name = "|foo|", 36 // custom JSON! 37 (testprotos.ffubar) = "abc", 38 (testprotos.ffubarb) = "xyz" 39 ]; // field trailer #1... 40 41 // lead mfubar 42 option (testprotos.mfubar) = true; // trailing mfubar 43 44 // some detached comments 45 46 // some detached comments with unicode θΏδΈͺζ―εΌ 47 48 // Another field comment 49 50 // label comment 51 optional /* type comment */ string /* name comment */ name = 2 [ 52 // default lead 53 54 default = "fubar" // default trail 55 ]; 56 57 extensions 100 to 200; 58 59 extensions 201 to 250 [ 60 (testprotos.exfubarb) = "\000\001\002\003\004\005\006\007", 61 (testprotos.exfubar) = "splat!" 62 ]; 63 64 reserved 10 to 20, 30 to 50; 65 66 reserved "foo", "bar", "baz"; 67 68 // Group comment with emoji π π π» β€ π― π₯ πΆ π¦ π₯ π» π π πͺ 69 optional group Extras = 3 { 70 // trailer for Extras 71 72 // this is a custom option 73 option (testprotos.mfubar) = false; 74 75 optional double dbl = 1; 76 77 optional float flt = 2; 78 79 option no_standard_descriptor_accessor = false; 80 81 // Leading comment... 82 optional string str = 3; // Trailing comment... 83 } 84 85 enum MarioCharacters /* "super"! */ { 86 // trailer for enum 87 88 // allow_alias comments! 89 option allow_alias = true; 90 91 MARIO = 1 [ 92 (testprotos.evfubars) = -314, 93 (testprotos.evfubar) = 278 94 ]; 95 96 LUIGI = 2 [ 97 (testprotos.evfubaruf) = 100, 98 // swoosh! 99 100 (testprotos.evfubaru) = 200 101 ]; 102 103 PEACH = 3; 104 105 BOWSER = 4; 106 107 option (testprotos.efubars) = -321; 108 109 WARIO = 5; 110 111 WALUIGI = 6; 112 113 SHY_GUY = 7 [(testprotos.evfubarsf) = 10101]; 114 115 HEY_HO = 7; 116 117 MAGIKOOPA = 8; 118 119 KAMEK = 8; 120 121 SNIFIT = -101; 122 123 option (testprotos.efubar) = 123; 124 } 125 126 // can be this or that 127 oneof abc { 128 // trailer for oneof abc 129 130 string this = 4; 131 132 int32 that = 5; 133 } 134 135 // can be these or those 136 oneof xyz { 137 // whoops? 138 option (testprotos.oofubar) = "whoops, this has invalid UTF8! \274\377"; 139 140 string these = 6; 141 142 int32 those = 7; 143 } 144 145 // map field 146 map<string, string> things = 8; 147 } 148 149 // And next we'll need some extensions... 150 151 extend /* extendee comment */ Request { 152 // trailer for extend block 153 154 // comment for guid1 155 optional uint64 guid1 = 123; 156 157 // ... and a comment for guid2 158 optional uint64 guid2 = 124; 159 } 160 161 message /* name leading comment */ AnEmptyMessage { 162 // trailer for AnEmptyMessage 163 164 } 165 166 // Service comment 167 service /* service name */ RpcService { 168 // service trailer 169 // that spans multiple lines 170 171 // option that sets field 172 option (testprotos.sfubar) = { id: 100, name: "bob" }; 173 174 option deprecated = false; // DEPRECATED! 175 176 option (testprotos.sfubare) = VALUE; 177 178 // Method comment 179 rpc /* rpc name */ StreamingRpc ( /* comment C */ stream Request ) returns ( /*comment E */ Request ); // compact method trailer 180 181 rpc UnaryRpc ( Request ) returns ( google.protobuf.Empty ) { 182 // trailer for method 183 184 // this RPC is deprecated! 185 option deprecated = true; 186 187 option (testprotos.mtfubar) = 12.340000; 188 189 option (testprotos.mtfubard) = 123.456000; 190 } 191 }