github.com/jhump/protoreflect@v1.16.0/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/jhump/protoreflect/internal/testprotos"  ;
    16  
    17  import public "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 with unicode θΏ™δΈͺζ˜―ε€Ό
    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 with emoji πŸ˜€ 😍 πŸ‘» ❀ πŸ’― πŸ’₯ 🐢 πŸ¦‚ πŸ₯‘ 🍻 🌍 πŸš• πŸͺ
    55  	optional group /* group name */ Extras = 3 {
    56  		// trailer for Extras
    57  
    58  		// this is a custom option
    59  		option (testprotos.mfubar) = false;
    60  
    61  		optional double dbl = 1;
    62  		optional float flt = 2;
    63  
    64  		option no_standard_descriptor_accessor = false;
    65  
    66  		// Leading comment...
    67  		optional string str = 3;
    68  		// Trailing comment...
    69  	}
    70  
    71  	enum MarioCharacters // "super"!
    72  	{ // trailer for enum
    73  
    74  		// allow_alias comments!
    75  		option allow_alias = true;
    76  
    77  		MARIO = 1 [(testprotos.evfubars) = -314, (testprotos.evfubar) = 278];
    78  		LUIGI = 2 [ (testprotos.evfubaruf) = 100, /* swoosh! */ (testprotos.evfubaru)=200];
    79  		PEACH = 3;
    80  		BOWSER = 4;
    81  
    82  		option (testprotos.efubars) = -321;
    83  
    84  		WARIO = 5;
    85  		WALUIGI = 6;
    86  		SHY_GUY = 7 [(testprotos.evfubarsf)=10101];
    87  		HEY_HO = 7;
    88  		MAGIKOOPA = 8;
    89  		KAMEK = 8;
    90  		SNIFIT = -101;
    91  
    92  		option (testprotos.efubar) = 123;
    93  	}
    94  
    95  	// can be this or that
    96  	oneof abc {
    97  		// trailer for oneof abc
    98  
    99  		string this = 4;
   100  		int32 that = 5;
   101  	}
   102  	// can be these or those
   103  	oneof xyz {
   104  		// whoops?
   105  		option (testprotos.oofubar) = "whoops, this has invalid UTF8! \xBC\xFF";
   106  
   107  		string these = 6;
   108  		int32 those = 7;
   109  	}
   110  
   111  	// map field
   112  	map<string, string> things = 8;
   113  }
   114  
   115  // And next we'll need some extensions...
   116  
   117  extend
   118  // extendee comment
   119  Request
   120  // extendee trailer
   121  {
   122  	// trailer for extend block
   123  
   124  	// comment for guid1
   125  	optional uint64 guid1 = 123;
   126  	// ... and a comment for guid2
   127  	optional uint64 guid2 = 124;
   128  }
   129  // after extend block
   130  
   131  message /* name leading comment */ AnEmptyMessage /* name trailing comment */ { /* trailer for AnEmptyMessage */ }
   132  
   133  // Service comment
   134  service /* service name */ RpcService {
   135  	// service trailer
   136  	// that spans multiple lines
   137  
   138  	// option that sets field
   139  	option(testprotos.sfubar).id= 100;
   140  	// another option that sets field
   141  	option(testprotos.sfubar).name= "bob";
   142  	option deprecated = false; // DEPRECATED!
   143  
   144  	option (testprotos.sfubare) = VALUE;
   145  
   146  	// Method comment
   147  	rpc /* rpc name */ StreamingRpc /* comment A */ (/* comment B */stream /* comment C */ Request)
   148  		returns /* comment D */ (/*comment E */ Request ) /* comment F */ ; // compact method trailer
   149  
   150  	rpc UnaryRpc (Request) returns (google.protobuf.Empty) { // trailer for method
   151  		// this RPC is deprecated!
   152  		option deprecated = true;
   153  		option (testprotos.mtfubar) = 12.34;
   154  		option (testprotos.mtfubard) = 123.456;
   155  	}
   156  }
   157  // another comment after service
   158  
   159  // Detached comment after all elements cannot be preserved...