| OLD | NEW |
| (Empty) |
| 1 // Protocol Buffers - Google's data interchange format | |
| 2 // Copyright 2008 Google Inc. All rights reserved. | |
| 3 // http://code.google.com/p/protobuf/ | |
| 4 // | |
| 5 // Redistribution and use in source and binary forms, with or without | |
| 6 // modification, are permitted provided that the following conditions are | |
| 7 // met: | |
| 8 // | |
| 9 // * Redistributions of source code must retain the above copyright | |
| 10 // notice, this list of conditions and the following disclaimer. | |
| 11 // * Redistributions in binary form must reproduce the above | |
| 12 // copyright notice, this list of conditions and the following disclaimer | |
| 13 // in the documentation and/or other materials provided with the | |
| 14 // distribution. | |
| 15 // * Neither the name of Google Inc. nor the names of its | |
| 16 // contributors may be used to endorse or promote products derived from | |
| 17 // this software without specific prior written permission. | |
| 18 // | |
| 19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 30 | |
| 31 // Author: kenton@google.com (Kenton Varda) | |
| 32 // Based on original Protocol Buffers design by | |
| 33 // Sanjay Ghemawat, Jeff Dean, and others. | |
| 34 // | |
| 35 // The messages in this file describe the definitions found in .proto files. | |
| 36 // A valid .proto file can be translated directly to a FileDescriptorProto | |
| 37 // without any other information (e.g. without reading its imports). | |
| 38 | |
| 39 | |
| 40 | |
| 41 package google.protobuf; | |
| 42 option java_package = "com.google.protobuf"; | |
| 43 option java_outer_classname = "DescriptorProtos"; | |
| 44 | |
| 45 // descriptor.proto must be optimized for speed because reflection-based | |
| 46 // algorithms don't work during bootstrapping. | |
| 47 option optimize_for = SPEED; | |
| 48 | |
| 49 // The protocol compiler can output a FileDescriptorSet containing the .proto | |
| 50 // files it parses. | |
| 51 message FileDescriptorSet { | |
| 52 repeated FileDescriptorProto file = 1; | |
| 53 } | |
| 54 | |
| 55 // Describes a complete .proto file. | |
| 56 message FileDescriptorProto { | |
| 57 optional string name = 1; // file name, relative to root of source tree | |
| 58 optional string package = 2; // e.g. "foo", "foo.bar", etc. | |
| 59 | |
| 60 // Names of files imported by this file. | |
| 61 repeated string dependency = 3; | |
| 62 // Indexes of the public imported files in the dependency list above. | |
| 63 repeated int32 public_dependency = 10; | |
| 64 // Indexes of the weak imported files in the dependency list. | |
| 65 // For Google-internal migration only. Do not use. | |
| 66 repeated int32 weak_dependency = 11; | |
| 67 | |
| 68 // All top-level definitions in this file. | |
| 69 repeated DescriptorProto message_type = 4; | |
| 70 repeated EnumDescriptorProto enum_type = 5; | |
| 71 repeated ServiceDescriptorProto service = 6; | |
| 72 repeated FieldDescriptorProto extension = 7; | |
| 73 | |
| 74 optional FileOptions options = 8; | |
| 75 | |
| 76 // This field contains optional information about the original source code. | |
| 77 // You may safely remove this entire field whithout harming runtime | |
| 78 // functionality of the descriptors -- the information is needed only by | |
| 79 // development tools. | |
| 80 optional SourceCodeInfo source_code_info = 9; | |
| 81 } | |
| 82 | |
| 83 // Describes a message type. | |
| 84 message DescriptorProto { | |
| 85 optional string name = 1; | |
| 86 | |
| 87 repeated FieldDescriptorProto field = 2; | |
| 88 repeated FieldDescriptorProto extension = 6; | |
| 89 | |
| 90 repeated DescriptorProto nested_type = 3; | |
| 91 repeated EnumDescriptorProto enum_type = 4; | |
| 92 | |
| 93 message ExtensionRange { | |
| 94 optional int32 start = 1; | |
| 95 optional int32 end = 2; | |
| 96 } | |
| 97 repeated ExtensionRange extension_range = 5; | |
| 98 | |
| 99 optional MessageOptions options = 7; | |
| 100 } | |
| 101 | |
| 102 // Describes a field within a message. | |
| 103 message FieldDescriptorProto { | |
| 104 enum Type { | |
| 105 // 0 is reserved for errors. | |
| 106 // Order is weird for historical reasons. | |
| 107 TYPE_DOUBLE = 1; | |
| 108 TYPE_FLOAT = 2; | |
| 109 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if | |
| 110 // negative values are likely. | |
| 111 TYPE_INT64 = 3; | |
| 112 TYPE_UINT64 = 4; | |
| 113 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if | |
| 114 // negative values are likely. | |
| 115 TYPE_INT32 = 5; | |
| 116 TYPE_FIXED64 = 6; | |
| 117 TYPE_FIXED32 = 7; | |
| 118 TYPE_BOOL = 8; | |
| 119 TYPE_STRING = 9; | |
| 120 TYPE_GROUP = 10; // Tag-delimited aggregate. | |
| 121 TYPE_MESSAGE = 11; // Length-delimited aggregate. | |
| 122 | |
| 123 // New in version 2. | |
| 124 TYPE_BYTES = 12; | |
| 125 TYPE_UINT32 = 13; | |
| 126 TYPE_ENUM = 14; | |
| 127 TYPE_SFIXED32 = 15; | |
| 128 TYPE_SFIXED64 = 16; | |
| 129 TYPE_SINT32 = 17; // Uses ZigZag encoding. | |
| 130 TYPE_SINT64 = 18; // Uses ZigZag encoding. | |
| 131 }; | |
| 132 | |
| 133 enum Label { | |
| 134 // 0 is reserved for errors | |
| 135 LABEL_OPTIONAL = 1; | |
| 136 LABEL_REQUIRED = 2; | |
| 137 LABEL_REPEATED = 3; | |
| 138 // TODO(sanjay): Should we add LABEL_MAP? | |
| 139 }; | |
| 140 | |
| 141 optional string name = 1; | |
| 142 optional int32 number = 3; | |
| 143 optional Label label = 4; | |
| 144 | |
| 145 // If type_name is set, this need not be set. If both this and type_name | |
| 146 // are set, this must be either TYPE_ENUM or TYPE_MESSAGE. | |
| 147 optional Type type = 5; | |
| 148 | |
| 149 // For message and enum types, this is the name of the type. If the name | |
| 150 // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping | |
| 151 // rules are used to find the type (i.e. first the nested types within this | |
| 152 // message are searched, then within the parent, on up to the root | |
| 153 // namespace). | |
| 154 optional string type_name = 6; | |
| 155 | |
| 156 // For extensions, this is the name of the type being extended. It is | |
| 157 // resolved in the same manner as type_name. | |
| 158 optional string extendee = 2; | |
| 159 | |
| 160 // For numeric types, contains the original text representation of the value. | |
| 161 // For booleans, "true" or "false". | |
| 162 // For strings, contains the default text contents (not escaped in any way). | |
| 163 // For bytes, contains the C escaped value. All bytes >= 128 are escaped. | |
| 164 // TODO(kenton): Base-64 encode? | |
| 165 optional string default_value = 7; | |
| 166 | |
| 167 optional FieldOptions options = 8; | |
| 168 } | |
| 169 | |
| 170 // Describes an enum type. | |
| 171 message EnumDescriptorProto { | |
| 172 optional string name = 1; | |
| 173 | |
| 174 repeated EnumValueDescriptorProto value = 2; | |
| 175 | |
| 176 optional EnumOptions options = 3; | |
| 177 } | |
| 178 | |
| 179 // Describes a value within an enum. | |
| 180 message EnumValueDescriptorProto { | |
| 181 optional string name = 1; | |
| 182 optional int32 number = 2; | |
| 183 | |
| 184 optional EnumValueOptions options = 3; | |
| 185 } | |
| 186 | |
| 187 // Describes a service. | |
| 188 message ServiceDescriptorProto { | |
| 189 optional string name = 1; | |
| 190 repeated MethodDescriptorProto method = 2; | |
| 191 | |
| 192 optional ServiceOptions options = 3; | |
| 193 } | |
| 194 | |
| 195 // Describes a method of a service. | |
| 196 message MethodDescriptorProto { | |
| 197 optional string name = 1; | |
| 198 | |
| 199 // Input and output type names. These are resolved in the same way as | |
| 200 // FieldDescriptorProto.type_name, but must refer to a message type. | |
| 201 optional string input_type = 2; | |
| 202 optional string output_type = 3; | |
| 203 | |
| 204 optional MethodOptions options = 4; | |
| 205 } | |
| 206 | |
| 207 | |
| 208 // =================================================================== | |
| 209 // Options | |
| 210 | |
| 211 // Each of the definitions above may have "options" attached. These are | |
| 212 // just annotations which may cause code to be generated slightly differently | |
| 213 // or may contain hints for code that manipulates protocol messages. | |
| 214 // | |
| 215 // Clients may define custom options as extensions of the *Options messages. | |
| 216 // These extensions may not yet be known at parsing time, so the parser cannot | |
| 217 // store the values in them. Instead it stores them in a field in the *Options | |
| 218 // message called uninterpreted_option. This field must have the same name | |
| 219 // across all *Options messages. We then use this field to populate the | |
| 220 // extensions when we build a descriptor, at which point all protos have been | |
| 221 // parsed and so all extensions are known. | |
| 222 // | |
| 223 // Extension numbers for custom options may be chosen as follows: | |
| 224 // * For options which will only be used within a single application or | |
| 225 // organization, or for experimental options, use field numbers 50000 | |
| 226 // through 99999. It is up to you to ensure that you do not use the | |
| 227 // same number for multiple options. | |
| 228 // * For options which will be published and used publicly by multiple | |
| 229 // independent entities, e-mail protobuf-global-extension-registry@google.com | |
| 230 // to reserve extension numbers. Simply provide your project name (e.g. | |
| 231 // Object-C plugin) and your porject website (if available) -- there's no need | |
| 232 // to explain how you intend to use them. Usually you only need one extension | |
| 233 // number. You can declare multiple options with only one extension number by | |
| 234 // putting them in a sub-message. See the Custom Options section of the docs | |
| 235 // for examples: | |
| 236 // http://code.google.com/apis/protocolbuffers/docs/proto.html#options | |
| 237 // If this turns out to be popular, a web service will be set up | |
| 238 // to automatically assign option numbers. | |
| 239 | |
| 240 | |
| 241 message FileOptions { | |
| 242 | |
| 243 // Sets the Java package where classes generated from this .proto will be | |
| 244 // placed. By default, the proto package is used, but this is often | |
| 245 // inappropriate because proto packages do not normally start with backwards | |
| 246 // domain names. | |
| 247 optional string java_package = 1; | |
| 248 | |
| 249 | |
| 250 // If set, all the classes from the .proto file are wrapped in a single | |
| 251 // outer class with the given name. This applies to both Proto1 | |
| 252 // (equivalent to the old "--one_java_file" option) and Proto2 (where | |
| 253 // a .proto always translates to a single class, but you may want to | |
| 254 // explicitly choose the class name). | |
| 255 optional string java_outer_classname = 8; | |
| 256 | |
| 257 // If set true, then the Java code generator will generate a separate .java | |
| 258 // file for each top-level message, enum, and service defined in the .proto | |
| 259 // file. Thus, these types will *not* be nested inside the outer class | |
| 260 // named by java_outer_classname. However, the outer class will still be | |
| 261 // generated to contain the file's getDescriptor() method as well as any | |
| 262 // top-level extensions defined in the file. | |
| 263 optional bool java_multiple_files = 10 [default=false]; | |
| 264 | |
| 265 // If set true, then the Java code generator will generate equals() and | |
| 266 // hashCode() methods for all messages defined in the .proto file. This is | |
| 267 // purely a speed optimization, as the AbstractMessage base class includes | |
| 268 // reflection-based implementations of these methods. | |
| 269 optional bool java_generate_equals_and_hash = 20 [default=false]; | |
| 270 | |
| 271 // Generated classes can be optimized for speed or code size. | |
| 272 enum OptimizeMode { | |
| 273 SPEED = 1; // Generate complete code for parsing, serialization, | |
| 274 // etc. | |
| 275 CODE_SIZE = 2; // Use ReflectionOps to implement these methods. | |
| 276 LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. | |
| 277 } | |
| 278 optional OptimizeMode optimize_for = 9 [default=SPEED]; | |
| 279 | |
| 280 // Sets the Go package where structs generated from this .proto will be | |
| 281 // placed. There is no default. | |
| 282 optional string go_package = 11; | |
| 283 | |
| 284 | |
| 285 | |
| 286 // Should generic services be generated in each language? "Generic" services | |
| 287 // are not specific to any particular RPC system. They are generated by the | |
| 288 // main code generators in each language (without additional plugins). | |
| 289 // Generic services were the only kind of service generation supported by | |
| 290 // early versions of proto2. | |
| 291 // | |
| 292 // Generic services are now considered deprecated in favor of using plugins | |
| 293 // that generate code specific to your particular RPC system. Therefore, | |
| 294 // these default to false. Old code which depends on generic services should | |
| 295 // explicitly set them to true. | |
| 296 optional bool cc_generic_services = 16 [default=false]; | |
| 297 optional bool java_generic_services = 17 [default=false]; | |
| 298 optional bool py_generic_services = 18 [default=false]; | |
| 299 | |
| 300 // The parser stores options it doesn't recognize here. See above. | |
| 301 repeated UninterpretedOption uninterpreted_option = 999; | |
| 302 | |
| 303 // Clients can define custom options in extensions of this message. See above. | |
| 304 extensions 1000 to max; | |
| 305 } | |
| 306 | |
| 307 message MessageOptions { | |
| 308 // Set true to use the old proto1 MessageSet wire format for extensions. | |
| 309 // This is provided for backwards-compatibility with the MessageSet wire | |
| 310 // format. You should not use this for any other reason: It's less | |
| 311 // efficient, has fewer features, and is more complicated. | |
| 312 // | |
| 313 // The message must be defined exactly as follows: | |
| 314 // message Foo { | |
| 315 // option message_set_wire_format = true; | |
| 316 // extensions 4 to max; | |
| 317 // } | |
| 318 // Note that the message cannot have any defined fields; MessageSets only | |
| 319 // have extensions. | |
| 320 // | |
| 321 // All extensions of your type must be singular messages; e.g. they cannot | |
| 322 // be int32s, enums, or repeated messages. | |
| 323 // | |
| 324 // Because this is an option, the above two restrictions are not enforced by | |
| 325 // the protocol compiler. | |
| 326 optional bool message_set_wire_format = 1 [default=false]; | |
| 327 | |
| 328 // Disables the generation of the standard "descriptor()" accessor, which can | |
| 329 // conflict with a field of the same name. This is meant to make migration | |
| 330 // from proto1 easier; new code should avoid fields named "descriptor". | |
| 331 optional bool no_standard_descriptor_accessor = 2 [default=false]; | |
| 332 | |
| 333 // The parser stores options it doesn't recognize here. See above. | |
| 334 repeated UninterpretedOption uninterpreted_option = 999; | |
| 335 | |
| 336 // Clients can define custom options in extensions of this message. See above. | |
| 337 extensions 1000 to max; | |
| 338 } | |
| 339 | |
| 340 message FieldOptions { | |
| 341 // The ctype option instructs the C++ code generator to use a different | |
| 342 // representation of the field than it normally would. See the specific | |
| 343 // options below. This option is not yet implemented in the open source | |
| 344 // release -- sorry, we'll try to include it in a future version! | |
| 345 optional CType ctype = 1 [default = STRING]; | |
| 346 enum CType { | |
| 347 // Default mode. | |
| 348 STRING = 0; | |
| 349 | |
| 350 CORD = 1; | |
| 351 | |
| 352 STRING_PIECE = 2; | |
| 353 } | |
| 354 // The packed option can be enabled for repeated primitive fields to enable | |
| 355 // a more efficient representation on the wire. Rather than repeatedly | |
| 356 // writing the tag and type for each element, the entire array is encoded as | |
| 357 // a single length-delimited blob. | |
| 358 optional bool packed = 2; | |
| 359 | |
| 360 | |
| 361 | |
| 362 // Should this field be parsed lazily? Lazy applies only to message-type | |
| 363 // fields. It means that when the outer message is initially parsed, the | |
| 364 // inner message's contents will not be parsed but instead stored in encoded | |
| 365 // form. The inner message will actually be parsed when it is first accessed. | |
| 366 // | |
| 367 // This is only a hint. Implementations are free to choose whether to use | |
| 368 // eager or lazy parsing regardless of the value of this option. However, | |
| 369 // setting this option true suggests that the protocol author believes that | |
| 370 // using lazy parsing on this field is worth the additional bookkeeping | |
| 371 // overhead typically needed to implement it. | |
| 372 // | |
| 373 // This option does not affect the public interface of any generated code; | |
| 374 // all method signatures remain the same. Furthermore, thread-safety of the | |
| 375 // interface is not affected by this option; const methods remain safe to | |
| 376 // call from multiple threads concurrently, while non-const methods continue | |
| 377 // to require exclusive access. | |
| 378 // | |
| 379 // | |
| 380 // Note that implementations may choose not to check required fields within | |
| 381 // a lazy sub-message. That is, calling IsInitialized() on the outher message | |
| 382 // may return true even if the inner message has missing required fields. | |
| 383 // This is necessary because otherwise the inner message would have to be | |
| 384 // parsed in order to perform the check, defeating the purpose of lazy | |
| 385 // parsing. An implementation which chooses not to check required fields | |
| 386 // must be consistent about it. That is, for any particular sub-message, the | |
| 387 // implementation must either *always* check its required fields, or *never* | |
| 388 // check its required fields, regardless of whether or not the message has | |
| 389 // been parsed. | |
| 390 optional bool lazy = 5 [default=false]; | |
| 391 | |
| 392 // Is this field deprecated? | |
| 393 // Depending on the target platform, this can emit Deprecated annotations | |
| 394 // for accessors, or it will be completely ignored; in the very least, this | |
| 395 // is a formalization for deprecating fields. | |
| 396 optional bool deprecated = 3 [default=false]; | |
| 397 | |
| 398 // EXPERIMENTAL. DO NOT USE. | |
| 399 // For "map" fields, the name of the field in the enclosed type that | |
| 400 // is the key for this map. For example, suppose we have: | |
| 401 // message Item { | |
| 402 // required string name = 1; | |
| 403 // required string value = 2; | |
| 404 // } | |
| 405 // message Config { | |
| 406 // repeated Item items = 1 [experimental_map_key="name"]; | |
| 407 // } | |
| 408 // In this situation, the map key for Item will be set to "name". | |
| 409 // TODO: Fully-implement this, then remove the "experimental_" prefix. | |
| 410 optional string experimental_map_key = 9; | |
| 411 | |
| 412 // For Google-internal migration only. Do not use. | |
| 413 optional bool weak = 10 [default=false]; | |
| 414 | |
| 415 // The parser stores options it doesn't recognize here. See above. | |
| 416 repeated UninterpretedOption uninterpreted_option = 999; | |
| 417 | |
| 418 // Clients can define custom options in extensions of this message. See above. | |
| 419 extensions 1000 to max; | |
| 420 } | |
| 421 | |
| 422 message EnumOptions { | |
| 423 | |
| 424 // Set this option to false to disallow mapping different tag names to a same | |
| 425 // value. | |
| 426 optional bool allow_alias = 2 [default=true]; | |
| 427 | |
| 428 // The parser stores options it doesn't recognize here. See above. | |
| 429 repeated UninterpretedOption uninterpreted_option = 999; | |
| 430 | |
| 431 // Clients can define custom options in extensions of this message. See above. | |
| 432 extensions 1000 to max; | |
| 433 } | |
| 434 | |
| 435 message EnumValueOptions { | |
| 436 // The parser stores options it doesn't recognize here. See above. | |
| 437 repeated UninterpretedOption uninterpreted_option = 999; | |
| 438 | |
| 439 // Clients can define custom options in extensions of this message. See above. | |
| 440 extensions 1000 to max; | |
| 441 } | |
| 442 | |
| 443 message ServiceOptions { | |
| 444 | |
| 445 // Note: Field numbers 1 through 32 are reserved for Google's internal RPC | |
| 446 // framework. We apologize for hoarding these numbers to ourselves, but | |
| 447 // we were already using them long before we decided to release Protocol | |
| 448 // Buffers. | |
| 449 | |
| 450 // The parser stores options it doesn't recognize here. See above. | |
| 451 repeated UninterpretedOption uninterpreted_option = 999; | |
| 452 | |
| 453 // Clients can define custom options in extensions of this message. See above. | |
| 454 extensions 1000 to max; | |
| 455 } | |
| 456 | |
| 457 message MethodOptions { | |
| 458 | |
| 459 // Note: Field numbers 1 through 32 are reserved for Google's internal RPC | |
| 460 // framework. We apologize for hoarding these numbers to ourselves, but | |
| 461 // we were already using them long before we decided to release Protocol | |
| 462 // Buffers. | |
| 463 | |
| 464 // The parser stores options it doesn't recognize here. See above. | |
| 465 repeated UninterpretedOption uninterpreted_option = 999; | |
| 466 | |
| 467 // Clients can define custom options in extensions of this message. See above. | |
| 468 extensions 1000 to max; | |
| 469 } | |
| 470 | |
| 471 | |
| 472 // A message representing a option the parser does not recognize. This only | |
| 473 // appears in options protos created by the compiler::Parser class. | |
| 474 // DescriptorPool resolves these when building Descriptor objects. Therefore, | |
| 475 // options protos in descriptor objects (e.g. returned by Descriptor::options(), | |
| 476 // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions | |
| 477 // in them. | |
| 478 message UninterpretedOption { | |
| 479 // The name of the uninterpreted option. Each string represents a segment in | |
| 480 // a dot-separated name. is_extension is true iff a segment represents an | |
| 481 // extension (denoted with parentheses in options specs in .proto files). | |
| 482 // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents | |
| 483 // "foo.(bar.baz).qux". | |
| 484 message NamePart { | |
| 485 required string name_part = 1; | |
| 486 required bool is_extension = 2; | |
| 487 } | |
| 488 repeated NamePart name = 2; | |
| 489 | |
| 490 // The value of the uninterpreted option, in whatever type the tokenizer | |
| 491 // identified it as during parsing. Exactly one of these should be set. | |
| 492 optional string identifier_value = 3; | |
| 493 optional uint64 positive_int_value = 4; | |
| 494 optional int64 negative_int_value = 5; | |
| 495 optional double double_value = 6; | |
| 496 optional bytes string_value = 7; | |
| 497 optional string aggregate_value = 8; | |
| 498 } | |
| 499 | |
| 500 // =================================================================== | |
| 501 // Optional source code info | |
| 502 | |
| 503 // Encapsulates information about the original source file from which a | |
| 504 // FileDescriptorProto was generated. | |
| 505 message SourceCodeInfo { | |
| 506 // A Location identifies a piece of source code in a .proto file which | |
| 507 // corresponds to a particular definition. This information is intended | |
| 508 // to be useful to IDEs, code indexers, documentation generators, and similar | |
| 509 // tools. | |
| 510 // | |
| 511 // For example, say we have a file like: | |
| 512 // message Foo { | |
| 513 // optional string foo = 1; | |
| 514 // } | |
| 515 // Let's look at just the field definition: | |
| 516 // optional string foo = 1; | |
| 517 // ^ ^^ ^^ ^ ^^^ | |
| 518 // a bc de f ghi | |
| 519 // We have the following locations: | |
| 520 // span path represents | |
| 521 // [a,i) [ 4, 0, 2, 0 ] The whole field definition. | |
| 522 // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). | |
| 523 // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). | |
| 524 // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). | |
| 525 // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). | |
| 526 // | |
| 527 // Notes: | |
| 528 // - A location may refer to a repeated field itself (i.e. not to any | |
| 529 // particular index within it). This is used whenever a set of elements are | |
| 530 // logically enclosed in a single code segment. For example, an entire | |
| 531 // extend block (possibly containing multiple extension definitions) will | |
| 532 // have an outer location whose path refers to the "extensions" repeated | |
| 533 // field without an index. | |
| 534 // - Multiple locations may have the same path. This happens when a single | |
| 535 // logical declaration is spread out across multiple places. The most | |
| 536 // obvious example is the "extend" block again -- there may be multiple | |
| 537 // extend blocks in the same scope, each of which will have the same path. | |
| 538 // - A location's span is not always a subset of its parent's span. For | |
| 539 // example, the "extendee" of an extension declaration appears at the | |
| 540 // beginning of the "extend" block and is shared by all extensions within | |
| 541 // the block. | |
| 542 // - Just because a location's span is a subset of some other location's span | |
| 543 // does not mean that it is a descendent. For example, a "group" defines | |
| 544 // both a type and a field in a single declaration. Thus, the locations | |
| 545 // corresponding to the type and field and their components will overlap. | |
| 546 // - Code which tries to interpret locations should probably be designed to | |
| 547 // ignore those that it doesn't understand, as more types of locations could | |
| 548 // be recorded in the future. | |
| 549 repeated Location location = 1; | |
| 550 message Location { | |
| 551 // Identifies which part of the FileDescriptorProto was defined at this | |
| 552 // location. | |
| 553 // | |
| 554 // Each element is a field number or an index. They form a path from | |
| 555 // the root FileDescriptorProto to the place where the definition. For | |
| 556 // example, this path: | |
| 557 // [ 4, 3, 2, 7, 1 ] | |
| 558 // refers to: | |
| 559 // file.message_type(3) // 4, 3 | |
| 560 // .field(7) // 2, 7 | |
| 561 // .name() // 1 | |
| 562 // This is because FileDescriptorProto.message_type has field number 4: | |
| 563 // repeated DescriptorProto message_type = 4; | |
| 564 // and DescriptorProto.field has field number 2: | |
| 565 // repeated FieldDescriptorProto field = 2; | |
| 566 // and FieldDescriptorProto.name has field number 1: | |
| 567 // optional string name = 1; | |
| 568 // | |
| 569 // Thus, the above path gives the location of a field name. If we removed | |
| 570 // the last element: | |
| 571 // [ 4, 3, 2, 7 ] | |
| 572 // this path refers to the whole field declaration (from the beginning | |
| 573 // of the label to the terminating semicolon). | |
| 574 repeated int32 path = 1 [packed=true]; | |
| 575 | |
| 576 // Always has exactly three or four elements: start line, start column, | |
| 577 // end line (optional, otherwise assumed same as start line), end column. | |
| 578 // These are packed into a single field for efficiency. Note that line | |
| 579 // and column numbers are zero-based -- typically you will want to add | |
| 580 // 1 to each before displaying to a user. | |
| 581 repeated int32 span = 2 [packed=true]; | |
| 582 | |
| 583 // If this SourceCodeInfo represents a complete declaration, these are any | |
| 584 // comments appearing before and after the declaration which appear to be | |
| 585 // attached to the declaration. | |
| 586 // | |
| 587 // A series of line comments appearing on consecutive lines, with no other | |
| 588 // tokens appearing on those lines, will be treated as a single comment. | |
| 589 // | |
| 590 // Only the comment content is provided; comment markers (e.g. //) are | |
| 591 // stripped out. For block comments, leading whitespace and an asterisk | |
| 592 // will be stripped from the beginning of each line other than the first. | |
| 593 // Newlines are included in the output. | |
| 594 // | |
| 595 // Examples: | |
| 596 // | |
| 597 // optional int32 foo = 1; // Comment attached to foo. | |
| 598 // // Comment attached to bar. | |
| 599 // optional int32 bar = 2; | |
| 600 // | |
| 601 // optional string baz = 3; | |
| 602 // // Comment attached to baz. | |
| 603 // // Another line attached to baz. | |
| 604 // | |
| 605 // // Comment attached to qux. | |
| 606 // // | |
| 607 // // Another line attached to qux. | |
| 608 // optional double qux = 4; | |
| 609 // | |
| 610 // optional string corge = 5; | |
| 611 // /* Block comment attached | |
| 612 // * to corge. Leading asterisks | |
| 613 // * will be removed. */ | |
| 614 // /* Block comment attached to | |
| 615 // * grault. */ | |
| 616 // optional int32 grault = 6; | |
| 617 optional string leading_comments = 3; | |
| 618 optional string trailing_comments = 4; | |
| 619 } | |
| 620 } | |
| OLD | NEW |