github.com/bakjos/protoreflect@v1.9.2/desc/protoprint/testfiles/descriptor-only-doc-comments.proto (about) 1 syntax = "proto2"; 2 3 package google.protobuf; 4 5 option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor"; 6 7 option java_package = "com.google.protobuf"; 8 9 option java_outer_classname = "DescriptorProtos"; 10 11 option csharp_namespace = "Google.Protobuf.Reflection"; 12 13 option objc_class_prefix = "GPB"; 14 15 option cc_enable_arenas = true; 16 17 option optimize_for = SPEED; 18 19 // The protocol compiler can output a FileDescriptorSet containing the .proto 20 // files it parses. 21 message FileDescriptorSet { 22 repeated FileDescriptorProto file = 1; 23 } 24 25 // Describes a complete .proto file. 26 message FileDescriptorProto { 27 optional string name = 1; 28 29 optional string package = 2; 30 31 // Names of files imported by this file. 32 repeated string dependency = 3; 33 34 // Indexes of the public imported files in the dependency list above. 35 repeated int32 public_dependency = 10; 36 37 // Indexes of the weak imported files in the dependency list. 38 // For Google-internal migration only. Do not use. 39 repeated int32 weak_dependency = 11; 40 41 // All top-level definitions in this file. 42 repeated DescriptorProto message_type = 4; 43 44 repeated EnumDescriptorProto enum_type = 5; 45 46 repeated ServiceDescriptorProto service = 6; 47 48 repeated FieldDescriptorProto extension = 7; 49 50 optional FileOptions options = 8; 51 52 // This field contains optional information about the original source code. 53 // You may safely remove this entire field without harming runtime 54 // functionality of the descriptors -- the information is needed only by 55 // development tools. 56 optional SourceCodeInfo source_code_info = 9; 57 58 // The syntax of the proto file. 59 // The supported values are "proto2" and "proto3". 60 optional string syntax = 12; 61 } 62 63 // Describes a message type. 64 message DescriptorProto { 65 optional string name = 1; 66 67 repeated FieldDescriptorProto field = 2; 68 69 repeated FieldDescriptorProto extension = 6; 70 71 repeated DescriptorProto nested_type = 3; 72 73 repeated EnumDescriptorProto enum_type = 4; 74 75 message ExtensionRange { 76 optional int32 start = 1; 77 78 optional int32 end = 2; 79 80 optional ExtensionRangeOptions options = 3; 81 } 82 83 repeated ExtensionRange extension_range = 5; 84 85 repeated OneofDescriptorProto oneof_decl = 8; 86 87 optional MessageOptions options = 7; 88 89 // Range of reserved tag numbers. Reserved tag numbers may not be used by 90 // fields or extension ranges in the same message. Reserved ranges may 91 // not overlap. 92 message ReservedRange { 93 optional int32 start = 1; 94 95 optional int32 end = 2; 96 } 97 98 repeated ReservedRange reserved_range = 9; 99 100 // Reserved field names, which may not be used by fields in the same message. 101 // A given name may only be reserved once. 102 repeated string reserved_name = 10; 103 } 104 105 message ExtensionRangeOptions { 106 // The parser stores options it doesn't recognize here. See above. 107 repeated UninterpretedOption uninterpreted_option = 999; 108 109 extensions 1000 to max; 110 } 111 112 // Describes a field within a message. 113 message FieldDescriptorProto { 114 enum Type { 115 // 0 is reserved for errors. 116 // Order is weird for historical reasons. 117 TYPE_DOUBLE = 1; 118 119 TYPE_FLOAT = 2; 120 121 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if 122 // negative values are likely. 123 TYPE_INT64 = 3; 124 125 TYPE_UINT64 = 4; 126 127 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if 128 // negative values are likely. 129 TYPE_INT32 = 5; 130 131 TYPE_FIXED64 = 6; 132 133 TYPE_FIXED32 = 7; 134 135 TYPE_BOOL = 8; 136 137 TYPE_STRING = 9; 138 139 // Tag-delimited aggregate. 140 // Group type is deprecated and not supported in proto3. However, Proto3 141 // implementations should still be able to parse the group wire format and 142 // treat group fields as unknown fields. 143 TYPE_GROUP = 10; 144 145 TYPE_MESSAGE = 11; 146 147 // New in version 2. 148 TYPE_BYTES = 12; 149 150 TYPE_UINT32 = 13; 151 152 TYPE_ENUM = 14; 153 154 TYPE_SFIXED32 = 15; 155 156 TYPE_SFIXED64 = 16; 157 158 TYPE_SINT32 = 17; 159 160 TYPE_SINT64 = 18; 161 } 162 163 enum Label { 164 // 0 is reserved for errors 165 LABEL_OPTIONAL = 1; 166 167 LABEL_REQUIRED = 2; 168 169 LABEL_REPEATED = 3; 170 } 171 172 optional string name = 1; 173 174 optional int32 number = 3; 175 176 optional Label label = 4; 177 178 // If type_name is set, this need not be set. If both this and type_name 179 // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. 180 optional Type type = 5; 181 182 // For message and enum types, this is the name of the type. If the name 183 // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping 184 // rules are used to find the type (i.e. first the nested types within this 185 // message are searched, then within the parent, on up to the root 186 // namespace). 187 optional string type_name = 6; 188 189 // For extensions, this is the name of the type being extended. It is 190 // resolved in the same manner as type_name. 191 optional string extendee = 2; 192 193 // For numeric types, contains the original text representation of the value. 194 // For booleans, "true" or "false". 195 // For strings, contains the default text contents (not escaped in any way). 196 // For bytes, contains the C escaped value. All bytes >= 128 are escaped. 197 // TODO(kenton): Base-64 encode? 198 optional string default_value = 7; 199 200 // If set, gives the index of a oneof in the containing type's oneof_decl 201 // list. This field is a member of that oneof. 202 optional int32 oneof_index = 9; 203 204 // JSON name of this field. The value is set by protocol compiler. If the 205 // user has set a "json_name" option on this field, that option's value 206 // will be used. Otherwise, it's deduced from the field's name by converting 207 // it to camelCase. 208 optional string json_name = 10; 209 210 optional FieldOptions options = 8; 211 212 // If true, this is a proto3 "optional". When a proto3 field is optional, it 213 // tracks presence regardless of field type. 214 // 215 // When proto3_optional is true, this field must be belong to a oneof to 216 // signal to old proto3 clients that presence is tracked for this field. This 217 // oneof is known as a "synthetic" oneof, and this field must be its sole 218 // member (each proto3 optional field gets its own synthetic oneof). Synthetic 219 // oneofs exist in the descriptor only, and do not generate any API. Synthetic 220 // oneofs must be ordered after all "real" oneofs. 221 // 222 // For message fields, proto3_optional doesn't create any semantic change, 223 // since non-repeated message fields always track presence. However it still 224 // indicates the semantic detail of whether the user wrote "optional" or not. 225 // This can be useful for round-tripping the .proto file. For consistency we 226 // give message fields a synthetic oneof also, even though it is not required 227 // to track presence. This is especially important because the parser can't 228 // tell if a field is a message or an enum, so it must always create a 229 // synthetic oneof. 230 // 231 // Proto2 optional fields do not set this flag, because they already indicate 232 // optional with `LABEL_OPTIONAL`. 233 optional bool proto3_optional = 17; 234 } 235 236 // Describes a oneof. 237 message OneofDescriptorProto { 238 optional string name = 1; 239 240 optional OneofOptions options = 2; 241 } 242 243 // Describes an enum type. 244 message EnumDescriptorProto { 245 optional string name = 1; 246 247 repeated EnumValueDescriptorProto value = 2; 248 249 optional EnumOptions options = 3; 250 251 // Range of reserved numeric values. Reserved values may not be used by 252 // entries in the same enum. Reserved ranges may not overlap. 253 // 254 // Note that this is distinct from DescriptorProto.ReservedRange in that it 255 // is inclusive such that it can appropriately represent the entire int32 256 // domain. 257 message EnumReservedRange { 258 optional int32 start = 1; 259 260 optional int32 end = 2; 261 } 262 263 // Range of reserved numeric values. Reserved numeric values may not be used 264 // by enum values in the same enum declaration. Reserved ranges may not 265 // overlap. 266 repeated EnumReservedRange reserved_range = 4; 267 268 // Reserved enum value names, which may not be reused. A given name may only 269 // be reserved once. 270 repeated string reserved_name = 5; 271 } 272 273 // Describes a value within an enum. 274 message EnumValueDescriptorProto { 275 optional string name = 1; 276 277 optional int32 number = 2; 278 279 optional EnumValueOptions options = 3; 280 } 281 282 // Describes a service. 283 message ServiceDescriptorProto { 284 optional string name = 1; 285 286 repeated MethodDescriptorProto method = 2; 287 288 optional ServiceOptions options = 3; 289 } 290 291 // Describes a method of a service. 292 message MethodDescriptorProto { 293 optional string name = 1; 294 295 // Input and output type names. These are resolved in the same way as 296 // FieldDescriptorProto.type_name, but must refer to a message type. 297 optional string input_type = 2; 298 299 optional string output_type = 3; 300 301 optional MethodOptions options = 4; 302 303 // Identifies if client streams multiple client messages 304 optional bool client_streaming = 5 [default = false]; 305 306 // Identifies if server streams multiple server messages 307 optional bool server_streaming = 6 [default = false]; 308 } 309 310 message FileOptions { 311 // Sets the Java package where classes generated from this .proto will be 312 // placed. By default, the proto package is used, but this is often 313 // inappropriate because proto packages do not normally start with backwards 314 // domain names. 315 optional string java_package = 1; 316 317 // If set, all the classes from the .proto file are wrapped in a single 318 // outer class with the given name. This applies to both Proto1 319 // (equivalent to the old "--one_java_file" option) and Proto2 (where 320 // a .proto always translates to a single class, but you may want to 321 // explicitly choose the class name). 322 optional string java_outer_classname = 8; 323 324 // If set true, then the Java code generator will generate a separate .java 325 // file for each top-level message, enum, and service defined in the .proto 326 // file. Thus, these types will *not* be nested inside the outer class 327 // named by java_outer_classname. However, the outer class will still be 328 // generated to contain the file's getDescriptor() method as well as any 329 // top-level extensions defined in the file. 330 optional bool java_multiple_files = 10 [default = false]; 331 332 // This option does nothing. 333 optional bool java_generate_equals_and_hash = 20 [deprecated = true]; 334 335 // If set true, then the Java2 code generator will generate code that 336 // throws an exception whenever an attempt is made to assign a non-UTF-8 337 // byte sequence to a string field. 338 // Message reflection will do the same. 339 // However, an extension field still accepts non-UTF-8 byte sequences. 340 // This option has no effect on when used with the lite runtime. 341 optional bool java_string_check_utf8 = 27 [default = false]; 342 343 // Generated classes can be optimized for speed or code size. 344 enum OptimizeMode { 345 SPEED = 1; 346 347 // etc. 348 CODE_SIZE = 2; 349 350 LITE_RUNTIME = 3; 351 } 352 353 optional OptimizeMode optimize_for = 9 [default = SPEED]; 354 355 // Sets the Go package where structs generated from this .proto will be 356 // placed. If omitted, the Go package will be derived from the following: 357 // - The basename of the package import path, if provided. 358 // - Otherwise, the package statement in the .proto file, if present. 359 // - Otherwise, the basename of the .proto file, without extension. 360 optional string go_package = 11; 361 362 // Should generic services be generated in each language? "Generic" services 363 // are not specific to any particular RPC system. They are generated by the 364 // main code generators in each language (without additional plugins). 365 // Generic services were the only kind of service generation supported by 366 // early versions of google.protobuf. 367 // 368 // Generic services are now considered deprecated in favor of using plugins 369 // that generate code specific to your particular RPC system. Therefore, 370 // these default to false. Old code which depends on generic services should 371 // explicitly set them to true. 372 optional bool cc_generic_services = 16 [default = false]; 373 374 optional bool java_generic_services = 17 [default = false]; 375 376 optional bool py_generic_services = 18 [default = false]; 377 378 optional bool php_generic_services = 42 [default = false]; 379 380 // Is this file deprecated? 381 // Depending on the target platform, this can emit Deprecated annotations 382 // for everything in the file, or it will be completely ignored; in the very 383 // least, this is a formalization for deprecating files. 384 optional bool deprecated = 23 [default = false]; 385 386 // Enables the use of arenas for the proto messages in this file. This applies 387 // only to generated classes for C++. 388 optional bool cc_enable_arenas = 31 [default = true]; 389 390 // Sets the objective c class prefix which is prepended to all objective c 391 // generated classes from this .proto. There is no default. 392 optional string objc_class_prefix = 36; 393 394 // Namespace for generated classes; defaults to the package. 395 optional string csharp_namespace = 37; 396 397 // By default Swift generators will take the proto package and CamelCase it 398 // replacing '.' with underscore and use that to prefix the types/symbols 399 // defined. When this options is provided, they will use this value instead 400 // to prefix the types/symbols defined. 401 optional string swift_prefix = 39; 402 403 // Sets the php class prefix which is prepended to all php generated classes 404 // from this .proto. Default is empty. 405 optional string php_class_prefix = 40; 406 407 // Use this option to change the namespace of php generated classes. Default 408 // is empty. When this option is empty, the package name will be used for 409 // determining the namespace. 410 optional string php_namespace = 41; 411 412 // Use this option to change the namespace of php generated metadata classes. 413 // Default is empty. When this option is empty, the proto file name will be 414 // used for determining the namespace. 415 optional string php_metadata_namespace = 44; 416 417 // Use this option to change the package of ruby generated classes. Default 418 // is empty. When this option is not set, the package name will be used for 419 // determining the ruby package. 420 optional string ruby_package = 45; 421 422 // The parser stores options it doesn't recognize here. 423 // See the documentation for the "Options" section above. 424 repeated UninterpretedOption uninterpreted_option = 999; 425 426 extensions 1000 to max; 427 428 reserved 38; 429 } 430 431 message MessageOptions { 432 // Set true to use the old proto1 MessageSet wire format for extensions. 433 // This is provided for backwards-compatibility with the MessageSet wire 434 // format. You should not use this for any other reason: It's less 435 // efficient, has fewer features, and is more complicated. 436 // 437 // The message must be defined exactly as follows: 438 // message Foo { 439 // option message_set_wire_format = true; 440 // extensions 4 to max; 441 // } 442 // Note that the message cannot have any defined fields; MessageSets only 443 // have extensions. 444 // 445 // All extensions of your type must be singular messages; e.g. they cannot 446 // be int32s, enums, or repeated messages. 447 // 448 // Because this is an option, the above two restrictions are not enforced by 449 // the protocol compiler. 450 optional bool message_set_wire_format = 1 [default = false]; 451 452 // Disables the generation of the standard "descriptor()" accessor, which can 453 // conflict with a field of the same name. This is meant to make migration 454 // from proto1 easier; new code should avoid fields named "descriptor". 455 optional bool no_standard_descriptor_accessor = 2 [default = false]; 456 457 // Is this message deprecated? 458 // Depending on the target platform, this can emit Deprecated annotations 459 // for the message, or it will be completely ignored; in the very least, 460 // this is a formalization for deprecating messages. 461 optional bool deprecated = 3 [default = false]; 462 463 // Whether the message is an automatically generated map entry type for the 464 // maps field. 465 // 466 // For maps fields: 467 // map<KeyType, ValueType> map_field = 1; 468 // The parsed descriptor looks like: 469 // message MapFieldEntry { 470 // option map_entry = true; 471 // optional KeyType key = 1; 472 // optional ValueType value = 2; 473 // } 474 // repeated MapFieldEntry map_field = 1; 475 // 476 // Implementations may choose not to generate the map_entry=true message, but 477 // use a native map in the target language to hold the keys and values. 478 // The reflection APIs in such implementations still need to work as 479 // if the field is a repeated message field. 480 // 481 // NOTE: Do not set the option in .proto files. Always use the maps syntax 482 // instead. The option should only be implicitly set by the proto compiler 483 // parser. 484 optional bool map_entry = 7; 485 486 reserved 8, 9; 487 488 // The parser stores options it doesn't recognize here. See above. 489 repeated UninterpretedOption uninterpreted_option = 999; 490 491 extensions 1000 to max; 492 } 493 494 message FieldOptions { 495 // The ctype option instructs the C++ code generator to use a different 496 // representation of the field than it normally would. See the specific 497 // options below. This option is not yet implemented in the open source 498 // release -- sorry, we'll try to include it in a future version! 499 optional CType ctype = 1 [default = STRING]; 500 501 enum CType { 502 // Default mode. 503 STRING = 0; 504 505 CORD = 1; 506 507 STRING_PIECE = 2; 508 } 509 510 // The packed option can be enabled for repeated primitive fields to enable 511 // a more efficient representation on the wire. Rather than repeatedly 512 // writing the tag and type for each element, the entire array is encoded as 513 // a single length-delimited blob. In proto3, only explicit setting it to 514 // false will avoid using packed encoding. 515 optional bool packed = 2; 516 517 // The jstype option determines the JavaScript type used for values of the 518 // field. The option is permitted only for 64 bit integral and fixed types 519 // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING 520 // is represented as JavaScript string, which avoids loss of precision that 521 // can happen when a large value is converted to a floating point JavaScript. 522 // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to 523 // use the JavaScript "number" type. The behavior of the default option 524 // JS_NORMAL is implementation dependent. 525 // 526 // This option is an enum to permit additional types to be added, e.g. 527 // goog.math.Integer. 528 optional JSType jstype = 6 [default = JS_NORMAL]; 529 530 enum JSType { 531 // Use the default type. 532 JS_NORMAL = 0; 533 534 // Use JavaScript strings. 535 JS_STRING = 1; 536 537 // Use JavaScript numbers. 538 JS_NUMBER = 2; 539 } 540 541 // Should this field be parsed lazily? Lazy applies only to message-type 542 // fields. It means that when the outer message is initially parsed, the 543 // inner message's contents will not be parsed but instead stored in encoded 544 // form. The inner message will actually be parsed when it is first accessed. 545 // 546 // This is only a hint. Implementations are free to choose whether to use 547 // eager or lazy parsing regardless of the value of this option. However, 548 // setting this option true suggests that the protocol author believes that 549 // using lazy parsing on this field is worth the additional bookkeeping 550 // overhead typically needed to implement it. 551 // 552 // This option does not affect the public interface of any generated code; 553 // all method signatures remain the same. Furthermore, thread-safety of the 554 // interface is not affected by this option; const methods remain safe to 555 // call from multiple threads concurrently, while non-const methods continue 556 // to require exclusive access. 557 // 558 // 559 // Note that implementations may choose not to check required fields within 560 // a lazy sub-message. That is, calling IsInitialized() on the outer message 561 // may return true even if the inner message has missing required fields. 562 // This is necessary because otherwise the inner message would have to be 563 // parsed in order to perform the check, defeating the purpose of lazy 564 // parsing. An implementation which chooses not to check required fields 565 // must be consistent about it. That is, for any particular sub-message, the 566 // implementation must either *always* check its required fields, or *never* 567 // check its required fields, regardless of whether or not the message has 568 // been parsed. 569 optional bool lazy = 5 [default = false]; 570 571 // Is this field deprecated? 572 // Depending on the target platform, this can emit Deprecated annotations 573 // for accessors, or it will be completely ignored; in the very least, this 574 // is a formalization for deprecating fields. 575 optional bool deprecated = 3 [default = false]; 576 577 // For Google-internal migration only. Do not use. 578 optional bool weak = 10 [default = false]; 579 580 // The parser stores options it doesn't recognize here. See above. 581 repeated UninterpretedOption uninterpreted_option = 999; 582 583 extensions 1000 to max; 584 585 reserved 4; 586 } 587 588 message OneofOptions { 589 // The parser stores options it doesn't recognize here. See above. 590 repeated UninterpretedOption uninterpreted_option = 999; 591 592 extensions 1000 to max; 593 } 594 595 message EnumOptions { 596 // Set this option to true to allow mapping different tag names to the same 597 // value. 598 optional bool allow_alias = 2; 599 600 // Is this enum deprecated? 601 // Depending on the target platform, this can emit Deprecated annotations 602 // for the enum, or it will be completely ignored; in the very least, this 603 // is a formalization for deprecating enums. 604 optional bool deprecated = 3 [default = false]; 605 606 reserved 5; 607 608 // The parser stores options it doesn't recognize here. See above. 609 repeated UninterpretedOption uninterpreted_option = 999; 610 611 extensions 1000 to max; 612 } 613 614 message EnumValueOptions { 615 // Is this enum value deprecated? 616 // Depending on the target platform, this can emit Deprecated annotations 617 // for the enum value, or it will be completely ignored; in the very least, 618 // this is a formalization for deprecating enum values. 619 optional bool deprecated = 1 [default = false]; 620 621 // The parser stores options it doesn't recognize here. See above. 622 repeated UninterpretedOption uninterpreted_option = 999; 623 624 extensions 1000 to max; 625 } 626 627 message ServiceOptions { 628 // Is this service deprecated? 629 // Depending on the target platform, this can emit Deprecated annotations 630 // for the service, or it will be completely ignored; in the very least, 631 // this is a formalization for deprecating services. 632 optional bool deprecated = 33 [default = false]; 633 634 // The parser stores options it doesn't recognize here. See above. 635 repeated UninterpretedOption uninterpreted_option = 999; 636 637 extensions 1000 to max; 638 } 639 640 message MethodOptions { 641 // Is this method deprecated? 642 // Depending on the target platform, this can emit Deprecated annotations 643 // for the method, or it will be completely ignored; in the very least, 644 // this is a formalization for deprecating methods. 645 optional bool deprecated = 33 [default = false]; 646 647 // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, 648 // or neither? HTTP based RPC implementation may choose GET verb for safe 649 // methods, and PUT verb for idempotent methods instead of the default POST. 650 enum IdempotencyLevel { 651 IDEMPOTENCY_UNKNOWN = 0; 652 653 NO_SIDE_EFFECTS = 1; 654 655 IDEMPOTENT = 2; 656 } 657 658 optional IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; 659 660 // The parser stores options it doesn't recognize here. See above. 661 repeated UninterpretedOption uninterpreted_option = 999; 662 663 extensions 1000 to max; 664 } 665 666 // A message representing a option the parser does not recognize. This only 667 // appears in options protos created by the compiler::Parser class. 668 // DescriptorPool resolves these when building Descriptor objects. Therefore, 669 // options protos in descriptor objects (e.g. returned by Descriptor::options(), 670 // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions 671 // in them. 672 message UninterpretedOption { 673 // The name of the uninterpreted option. Each string represents a segment in 674 // a dot-separated name. is_extension is true iff a segment represents an 675 // extension (denoted with parentheses in options specs in .proto files). 676 // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents 677 // "foo.(bar.baz).qux". 678 message NamePart { 679 required string name_part = 1; 680 681 required bool is_extension = 2; 682 } 683 684 repeated NamePart name = 2; 685 686 // The value of the uninterpreted option, in whatever type the tokenizer 687 // identified it as during parsing. Exactly one of these should be set. 688 optional string identifier_value = 3; 689 690 optional uint64 positive_int_value = 4; 691 692 optional int64 negative_int_value = 5; 693 694 optional double double_value = 6; 695 696 optional bytes string_value = 7; 697 698 optional string aggregate_value = 8; 699 } 700 701 // Encapsulates information about the original source file from which a 702 // FileDescriptorProto was generated. 703 message SourceCodeInfo { 704 // A Location identifies a piece of source code in a .proto file which 705 // corresponds to a particular definition. This information is intended 706 // to be useful to IDEs, code indexers, documentation generators, and similar 707 // tools. 708 // 709 // For example, say we have a file like: 710 // message Foo { 711 // optional string foo = 1; 712 // } 713 // Let's look at just the field definition: 714 // optional string foo = 1; 715 // ^ ^^ ^^ ^ ^^^ 716 // a bc de f ghi 717 // We have the following locations: 718 // span path represents 719 // [a,i) [ 4, 0, 2, 0 ] The whole field definition. 720 // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). 721 // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). 722 // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). 723 // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). 724 // 725 // Notes: 726 // - A location may refer to a repeated field itself (i.e. not to any 727 // particular index within it). This is used whenever a set of elements are 728 // logically enclosed in a single code segment. For example, an entire 729 // extend block (possibly containing multiple extension definitions) will 730 // have an outer location whose path refers to the "extensions" repeated 731 // field without an index. 732 // - Multiple locations may have the same path. This happens when a single 733 // logical declaration is spread out across multiple places. The most 734 // obvious example is the "extend" block again -- there may be multiple 735 // extend blocks in the same scope, each of which will have the same path. 736 // - A location's span is not always a subset of its parent's span. For 737 // example, the "extendee" of an extension declaration appears at the 738 // beginning of the "extend" block and is shared by all extensions within 739 // the block. 740 // - Just because a location's span is a subset of some other location's span 741 // does not mean that it is a descendant. For example, a "group" defines 742 // both a type and a field in a single declaration. Thus, the locations 743 // corresponding to the type and field and their components will overlap. 744 // - Code which tries to interpret locations should probably be designed to 745 // ignore those that it doesn't understand, as more types of locations could 746 // be recorded in the future. 747 repeated Location location = 1; 748 749 message Location { 750 // Identifies which part of the FileDescriptorProto was defined at this 751 // location. 752 // 753 // Each element is a field number or an index. They form a path from 754 // the root FileDescriptorProto to the place where the definition. For 755 // example, this path: 756 // [ 4, 3, 2, 7, 1 ] 757 // refers to: 758 // file.message_type(3) // 4, 3 759 // .field(7) // 2, 7 760 // .name() // 1 761 // This is because FileDescriptorProto.message_type has field number 4: 762 // repeated DescriptorProto message_type = 4; 763 // and DescriptorProto.field has field number 2: 764 // repeated FieldDescriptorProto field = 2; 765 // and FieldDescriptorProto.name has field number 1: 766 // optional string name = 1; 767 // 768 // Thus, the above path gives the location of a field name. If we removed 769 // the last element: 770 // [ 4, 3, 2, 7 ] 771 // this path refers to the whole field declaration (from the beginning 772 // of the label to the terminating semicolon). 773 repeated int32 path = 1 [packed = true]; 774 775 // Always has exactly three or four elements: start line, start column, 776 // end line (optional, otherwise assumed same as start line), end column. 777 // These are packed into a single field for efficiency. Note that line 778 // and column numbers are zero-based -- typically you will want to add 779 // 1 to each before displaying to a user. 780 repeated int32 span = 2 [packed = true]; 781 782 // If this SourceCodeInfo represents a complete declaration, these are any 783 // comments appearing before and after the declaration which appear to be 784 // attached to the declaration. 785 // 786 // A series of line comments appearing on consecutive lines, with no other 787 // tokens appearing on those lines, will be treated as a single comment. 788 // 789 // leading_detached_comments will keep paragraphs of comments that appear 790 // before (but not connected to) the current element. Each paragraph, 791 // separated by empty lines, will be one comment element in the repeated 792 // field. 793 // 794 // Only the comment content is provided; comment markers (e.g. //) are 795 // stripped out. For block comments, leading whitespace and an asterisk 796 // will be stripped from the beginning of each line other than the first. 797 // Newlines are included in the output. 798 // 799 // Examples: 800 // 801 // optional int32 foo = 1; // Comment attached to foo. 802 // // Comment attached to bar. 803 // optional int32 bar = 2; 804 // 805 // optional string baz = 3; 806 // // Comment attached to baz. 807 // // Another line attached to baz. 808 // 809 // // Comment attached to qux. 810 // // 811 // // Another line attached to qux. 812 // optional double qux = 4; 813 // 814 // // Detached comment for corge. This is not leading or trailing comments 815 // // to qux or corge because there are blank lines separating it from 816 // // both. 817 // 818 // // Detached comment for corge paragraph 2. 819 // 820 // optional string corge = 5; 821 // /* Block comment attached 822 // * to corge. Leading asterisks 823 // * will be removed. */ 824 // /* Block comment attached to 825 // * grault. */ 826 // optional int32 grault = 6; 827 // 828 // // ignored detached comments. 829 optional string leading_comments = 3; 830 831 optional string trailing_comments = 4; 832 833 repeated string leading_detached_comments = 6; 834 } 835 } 836 837 // Describes the relationship between generated code and its original source 838 // file. A GeneratedCodeInfo message is associated with only one generated 839 // source file, but may contain references to different source .proto files. 840 message GeneratedCodeInfo { 841 // An Annotation connects some span of text in generated code to an element 842 // of its generating .proto file. 843 repeated Annotation annotation = 1; 844 845 message Annotation { 846 // Identifies the element in the original source .proto file. This field 847 // is formatted the same as SourceCodeInfo.Location.path. 848 repeated int32 path = 1 [packed = true]; 849 850 // Identifies the filesystem path to the original source .proto. 851 optional string source_file = 2; 852 853 // Identifies the starting offset in bytes in the generated code 854 // that relates to the identified object. 855 optional int32 begin = 3; 856 857 // Identifies the ending offset in bytes in the generated code that 858 // relates to the identified offset. The end offset should be one past 859 // the last relevant byte (so the length of the text = end - begin). 860 optional int32 end = 4; 861 } 862 }