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