descriptor.proto 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  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. // Author: kenton@google.com (Kenton Varda)
  31. // Based on original Protocol Buffers design by
  32. // Sanjay Ghemawat, Jeff Dean, and others.
  33. //
  34. // The messages in this file describe the definitions found in .proto files.
  35. // A valid .proto file can be translated directly to a FileDescriptorProto
  36. // without any other information (e.g. without reading its imports).
  37. syntax = "proto2";
  38. package google.protobuf;
  39. option go_package = "google.golang.org/protobuf/types/descriptorpb";
  40. option java_package = "com.google.protobuf";
  41. option java_outer_classname = "DescriptorProtos";
  42. option csharp_namespace = "Google.Protobuf.Reflection";
  43. option objc_class_prefix = "GPB";
  44. option cc_enable_arenas = true;
  45. // descriptor.proto must be optimized for speed because reflection-based
  46. // algorithms don't work during bootstrapping.
  47. option optimize_for = SPEED;
  48. // The protocol compiler can output a FileDescriptorSet containing the .proto
  49. // files it parses.
  50. message FileDescriptorSet {
  51. repeated FileDescriptorProto file = 1;
  52. }
  53. // The full set of known editions.
  54. enum Edition {
  55. // A placeholder for an unknown edition value.
  56. EDITION_UNKNOWN = 0;
  57. // A placeholder edition for specifying default behaviors *before* a feature
  58. // was first introduced. This is effectively an "infinite past".
  59. EDITION_LEGACY = 900;
  60. // Legacy syntax "editions". These pre-date editions, but behave much like
  61. // distinct editions. These can't be used to specify the edition of proto
  62. // files, but feature definitions must supply proto2/proto3 defaults for
  63. // backwards compatibility.
  64. EDITION_PROTO2 = 998;
  65. EDITION_PROTO3 = 999;
  66. // Editions that have been released. The specific values are arbitrary and
  67. // should not be depended on, but they will always be time-ordered for easy
  68. // comparison.
  69. EDITION_2023 = 1000;
  70. EDITION_2024 = 1001;
  71. // Placeholder editions for testing feature resolution. These should not be
  72. // used or relied on outside of tests.
  73. EDITION_1_TEST_ONLY = 1;
  74. EDITION_2_TEST_ONLY = 2;
  75. EDITION_99997_TEST_ONLY = 99997;
  76. EDITION_99998_TEST_ONLY = 99998;
  77. EDITION_99999_TEST_ONLY = 99999;
  78. // Placeholder for specifying unbounded edition support. This should only
  79. // ever be used by plugins that can expect to never require any changes to
  80. // support a new edition.
  81. EDITION_MAX = 0x7FFFFFFF;
  82. }
  83. // Describes a complete .proto file.
  84. message FileDescriptorProto {
  85. optional string name = 1; // file name, relative to root of source tree
  86. optional string package = 2; // e.g. "foo", "foo.bar", etc.
  87. // Names of files imported by this file.
  88. repeated string dependency = 3;
  89. // Indexes of the public imported files in the dependency list above.
  90. repeated int32 public_dependency = 10;
  91. // Indexes of the weak imported files in the dependency list.
  92. // For Google-internal migration only. Do not use.
  93. repeated int32 weak_dependency = 11;
  94. // All top-level definitions in this file.
  95. repeated DescriptorProto message_type = 4;
  96. repeated EnumDescriptorProto enum_type = 5;
  97. repeated ServiceDescriptorProto service = 6;
  98. repeated FieldDescriptorProto extension = 7;
  99. optional FileOptions options = 8;
  100. // This field contains optional information about the original source code.
  101. // You may safely remove this entire field without harming runtime
  102. // functionality of the descriptors -- the information is needed only by
  103. // development tools.
  104. optional SourceCodeInfo source_code_info = 9;
  105. // The syntax of the proto file.
  106. // The supported values are "proto2", "proto3", and "editions".
  107. //
  108. // If `edition` is present, this value must be "editions".
  109. optional string syntax = 12;
  110. // The edition of the proto file.
  111. optional Edition edition = 14;
  112. }
  113. // Describes a message type.
  114. message DescriptorProto {
  115. optional string name = 1;
  116. repeated FieldDescriptorProto field = 2;
  117. repeated FieldDescriptorProto extension = 6;
  118. repeated DescriptorProto nested_type = 3;
  119. repeated EnumDescriptorProto enum_type = 4;
  120. message ExtensionRange {
  121. optional int32 start = 1; // Inclusive.
  122. optional int32 end = 2; // Exclusive.
  123. optional ExtensionRangeOptions options = 3;
  124. }
  125. repeated ExtensionRange extension_range = 5;
  126. repeated OneofDescriptorProto oneof_decl = 8;
  127. optional MessageOptions options = 7;
  128. // Range of reserved tag numbers. Reserved tag numbers may not be used by
  129. // fields or extension ranges in the same message. Reserved ranges may
  130. // not overlap.
  131. message ReservedRange {
  132. optional int32 start = 1; // Inclusive.
  133. optional int32 end = 2; // Exclusive.
  134. }
  135. repeated ReservedRange reserved_range = 9;
  136. // Reserved field names, which may not be used by fields in the same message.
  137. // A given name may only be reserved once.
  138. repeated string reserved_name = 10;
  139. }
  140. message ExtensionRangeOptions {
  141. // The parser stores options it doesn't recognize here. See above.
  142. repeated UninterpretedOption uninterpreted_option = 999;
  143. message Declaration {
  144. // The extension number declared within the extension range.
  145. optional int32 number = 1;
  146. // The fully-qualified name of the extension field. There must be a leading
  147. // dot in front of the full name.
  148. optional string full_name = 2;
  149. // The fully-qualified type name of the extension field. Unlike
  150. // Metadata.type, Declaration.type must have a leading dot for messages
  151. // and enums.
  152. optional string type = 3;
  153. // If true, indicates that the number is reserved in the extension range,
  154. // and any extension field with the number will fail to compile. Set this
  155. // when a declared extension field is deleted.
  156. optional bool reserved = 5;
  157. // If true, indicates that the extension must be defined as repeated.
  158. // Otherwise the extension must be defined as optional.
  159. optional bool repeated = 6;
  160. reserved 4; // removed is_repeated
  161. }
  162. // For external users: DO NOT USE. We are in the process of open sourcing
  163. // extension declaration and executing internal cleanups before it can be
  164. // used externally.
  165. repeated Declaration declaration = 2 [retention = RETENTION_SOURCE];
  166. // Any features defined in the specific edition.
  167. optional FeatureSet features = 50;
  168. // The verification state of the extension range.
  169. enum VerificationState {
  170. // All the extensions of the range must be declared.
  171. DECLARATION = 0;
  172. UNVERIFIED = 1;
  173. }
  174. // The verification state of the range.
  175. // TODO: flip the default to DECLARATION once all empty ranges
  176. // are marked as UNVERIFIED.
  177. optional VerificationState verification = 3
  178. [default = UNVERIFIED, retention = RETENTION_SOURCE];
  179. // Clients can define custom options in extensions of this message. See above.
  180. extensions 1000 to max;
  181. }
  182. // Describes a field within a message.
  183. message FieldDescriptorProto {
  184. enum Type {
  185. // 0 is reserved for errors.
  186. // Order is weird for historical reasons.
  187. TYPE_DOUBLE = 1;
  188. TYPE_FLOAT = 2;
  189. // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
  190. // negative values are likely.
  191. TYPE_INT64 = 3;
  192. TYPE_UINT64 = 4;
  193. // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
  194. // negative values are likely.
  195. TYPE_INT32 = 5;
  196. TYPE_FIXED64 = 6;
  197. TYPE_FIXED32 = 7;
  198. TYPE_BOOL = 8;
  199. TYPE_STRING = 9;
  200. // Tag-delimited aggregate.
  201. // Group type is deprecated and not supported after google.protobuf. However, Proto3
  202. // implementations should still be able to parse the group wire format and
  203. // treat group fields as unknown fields. In Editions, the group wire format
  204. // can be enabled via the `message_encoding` feature.
  205. TYPE_GROUP = 10;
  206. TYPE_MESSAGE = 11; // Length-delimited aggregate.
  207. // New in version 2.
  208. TYPE_BYTES = 12;
  209. TYPE_UINT32 = 13;
  210. TYPE_ENUM = 14;
  211. TYPE_SFIXED32 = 15;
  212. TYPE_SFIXED64 = 16;
  213. TYPE_SINT32 = 17; // Uses ZigZag encoding.
  214. TYPE_SINT64 = 18; // Uses ZigZag encoding.
  215. }
  216. enum Label {
  217. // 0 is reserved for errors
  218. LABEL_OPTIONAL = 1;
  219. LABEL_REPEATED = 3;
  220. // The required label is only allowed in google.protobuf. In proto3 and Editions
  221. // it's explicitly prohibited. In Editions, the `field_presence` feature
  222. // can be used to get this behavior.
  223. LABEL_REQUIRED = 2;
  224. }
  225. optional string name = 1;
  226. optional int32 number = 3;
  227. optional Label label = 4;
  228. // If type_name is set, this need not be set. If both this and type_name
  229. // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
  230. optional Type type = 5;
  231. // For message and enum types, this is the name of the type. If the name
  232. // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
  233. // rules are used to find the type (i.e. first the nested types within this
  234. // message are searched, then within the parent, on up to the root
  235. // namespace).
  236. optional string type_name = 6;
  237. // For extensions, this is the name of the type being extended. It is
  238. // resolved in the same manner as type_name.
  239. optional string extendee = 2;
  240. // For numeric types, contains the original text representation of the value.
  241. // For booleans, "true" or "false".
  242. // For strings, contains the default text contents (not escaped in any way).
  243. // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
  244. optional string default_value = 7;
  245. // If set, gives the index of a oneof in the containing type's oneof_decl
  246. // list. This field is a member of that oneof.
  247. optional int32 oneof_index = 9;
  248. // JSON name of this field. The value is set by protocol compiler. If the
  249. // user has set a "json_name" option on this field, that option's value
  250. // will be used. Otherwise, it's deduced from the field's name by converting
  251. // it to camelCase.
  252. optional string json_name = 10;
  253. optional FieldOptions options = 8;
  254. // If true, this is a proto3 "optional". When a proto3 field is optional, it
  255. // tracks presence regardless of field type.
  256. //
  257. // When proto3_optional is true, this field must belong to a oneof to signal
  258. // to old proto3 clients that presence is tracked for this field. This oneof
  259. // is known as a "synthetic" oneof, and this field must be its sole member
  260. // (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs
  261. // exist in the descriptor only, and do not generate any API. Synthetic oneofs
  262. // must be ordered after all "real" oneofs.
  263. //
  264. // For message fields, proto3_optional doesn't create any semantic change,
  265. // since non-repeated message fields always track presence. However it still
  266. // indicates the semantic detail of whether the user wrote "optional" or not.
  267. // This can be useful for round-tripping the .proto file. For consistency we
  268. // give message fields a synthetic oneof also, even though it is not required
  269. // to track presence. This is especially important because the parser can't
  270. // tell if a field is a message or an enum, so it must always create a
  271. // synthetic oneof.
  272. //
  273. // Proto2 optional fields do not set this flag, because they already indicate
  274. // optional with `LABEL_OPTIONAL`.
  275. optional bool proto3_optional = 17;
  276. }
  277. // Describes a oneof.
  278. message OneofDescriptorProto {
  279. optional string name = 1;
  280. optional OneofOptions options = 2;
  281. }
  282. // Describes an enum type.
  283. message EnumDescriptorProto {
  284. optional string name = 1;
  285. repeated EnumValueDescriptorProto value = 2;
  286. optional EnumOptions options = 3;
  287. // Range of reserved numeric values. Reserved values may not be used by
  288. // entries in the same enum. Reserved ranges may not overlap.
  289. //
  290. // Note that this is distinct from DescriptorProto.ReservedRange in that it
  291. // is inclusive such that it can appropriately represent the entire int32
  292. // domain.
  293. message EnumReservedRange {
  294. optional int32 start = 1; // Inclusive.
  295. optional int32 end = 2; // Inclusive.
  296. }
  297. // Range of reserved numeric values. Reserved numeric values may not be used
  298. // by enum values in the same enum declaration. Reserved ranges may not
  299. // overlap.
  300. repeated EnumReservedRange reserved_range = 4;
  301. // Reserved enum value names, which may not be reused. A given name may only
  302. // be reserved once.
  303. repeated string reserved_name = 5;
  304. }
  305. // Describes a value within an enum.
  306. message EnumValueDescriptorProto {
  307. optional string name = 1;
  308. optional int32 number = 2;
  309. optional EnumValueOptions options = 3;
  310. }
  311. // Describes a service.
  312. message ServiceDescriptorProto {
  313. optional string name = 1;
  314. repeated MethodDescriptorProto method = 2;
  315. optional ServiceOptions options = 3;
  316. }
  317. // Describes a method of a service.
  318. message MethodDescriptorProto {
  319. optional string name = 1;
  320. // Input and output type names. These are resolved in the same way as
  321. // FieldDescriptorProto.type_name, but must refer to a message type.
  322. optional string input_type = 2;
  323. optional string output_type = 3;
  324. optional MethodOptions options = 4;
  325. // Identifies if client streams multiple client messages
  326. optional bool client_streaming = 5 [default = false];
  327. // Identifies if server streams multiple server messages
  328. optional bool server_streaming = 6 [default = false];
  329. }
  330. // ===================================================================
  331. // Options
  332. // Each of the definitions above may have "options" attached. These are
  333. // just annotations which may cause code to be generated slightly differently
  334. // or may contain hints for code that manipulates protocol messages.
  335. //
  336. // Clients may define custom options as extensions of the *Options messages.
  337. // These extensions may not yet be known at parsing time, so the parser cannot
  338. // store the values in them. Instead it stores them in a field in the *Options
  339. // message called uninterpreted_option. This field must have the same name
  340. // across all *Options messages. We then use this field to populate the
  341. // extensions when we build a descriptor, at which point all protos have been
  342. // parsed and so all extensions are known.
  343. //
  344. // Extension numbers for custom options may be chosen as follows:
  345. // * For options which will only be used within a single application or
  346. // organization, or for experimental options, use field numbers 50000
  347. // through 99999. It is up to you to ensure that you do not use the
  348. // same number for multiple options.
  349. // * For options which will be published and used publicly by multiple
  350. // independent entities, e-mail protobuf-global-extension-registry@google.com
  351. // to reserve extension numbers. Simply provide your project name (e.g.
  352. // Objective-C plugin) and your project website (if available) -- there's no
  353. // need to explain how you intend to use them. Usually you only need one
  354. // extension number. You can declare multiple options with only one extension
  355. // number by putting them in a sub-message. See the Custom Options section of
  356. // the docs for examples:
  357. // https://developers.google.com/protocol-buffers/docs/proto#options
  358. // If this turns out to be popular, a web service will be set up
  359. // to automatically assign option numbers.
  360. message FileOptions {
  361. // Sets the Java package where classes generated from this .proto will be
  362. // placed. By default, the proto package is used, but this is often
  363. // inappropriate because proto packages do not normally start with backwards
  364. // domain names.
  365. optional string java_package = 1;
  366. // Controls the name of the wrapper Java class generated for the .proto file.
  367. // That class will always contain the .proto file's getDescriptor() method as
  368. // well as any top-level extensions defined in the .proto file.
  369. // If java_multiple_files is disabled, then all the other classes from the
  370. // .proto file will be nested inside the single wrapper outer class.
  371. optional string java_outer_classname = 8;
  372. // If enabled, then the Java code generator will generate a separate .java
  373. // file for each top-level message, enum, and service defined in the .proto
  374. // file. Thus, these types will *not* be nested inside the wrapper class
  375. // named by java_outer_classname. However, the wrapper class will still be
  376. // generated to contain the file's getDescriptor() method as well as any
  377. // top-level extensions defined in the file.
  378. optional bool java_multiple_files = 10 [default = false];
  379. // This option does nothing.
  380. optional bool java_generate_equals_and_hash = 20 [deprecated=true];
  381. // A proto2 file can set this to true to opt in to UTF-8 checking for Java,
  382. // which will throw an exception if invalid UTF-8 is parsed from the wire or
  383. // assigned to a string field.
  384. //
  385. // TODO: clarify exactly what kinds of field types this option
  386. // applies to, and update these docs accordingly.
  387. //
  388. // Proto3 files already perform these checks. Setting the option explicitly to
  389. // false has no effect: it cannot be used to opt proto3 files out of UTF-8
  390. // checks.
  391. optional bool java_string_check_utf8 = 27 [default = false];
  392. // Generated classes can be optimized for speed or code size.
  393. enum OptimizeMode {
  394. SPEED = 1; // Generate complete code for parsing, serialization,
  395. // etc.
  396. CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
  397. LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
  398. }
  399. optional OptimizeMode optimize_for = 9 [default = SPEED];
  400. // Sets the Go package where structs generated from this .proto will be
  401. // placed. If omitted, the Go package will be derived from the following:
  402. // - The basename of the package import path, if provided.
  403. // - Otherwise, the package statement in the .proto file, if present.
  404. // - Otherwise, the basename of the .proto file, without extension.
  405. optional string go_package = 11;
  406. // Should generic services be generated in each language? "Generic" services
  407. // are not specific to any particular RPC system. They are generated by the
  408. // main code generators in each language (without additional plugins).
  409. // Generic services were the only kind of service generation supported by
  410. // early versions of google.protobuf.
  411. //
  412. // Generic services are now considered deprecated in favor of using plugins
  413. // that generate code specific to your particular RPC system. Therefore,
  414. // these default to false. Old code which depends on generic services should
  415. // explicitly set them to true.
  416. optional bool cc_generic_services = 16 [default = false];
  417. optional bool java_generic_services = 17 [default = false];
  418. optional bool py_generic_services = 18 [default = false];
  419. reserved 42; // removed php_generic_services
  420. reserved "php_generic_services";
  421. // Is this file deprecated?
  422. // Depending on the target platform, this can emit Deprecated annotations
  423. // for everything in the file, or it will be completely ignored; in the very
  424. // least, this is a formalization for deprecating files.
  425. optional bool deprecated = 23 [default = false];
  426. // Enables the use of arenas for the proto messages in this file. This applies
  427. // only to generated classes for C++.
  428. optional bool cc_enable_arenas = 31 [default = true];
  429. // Sets the objective c class prefix which is prepended to all objective c
  430. // generated classes from this .proto. There is no default.
  431. optional string objc_class_prefix = 36;
  432. // Namespace for generated classes; defaults to the package.
  433. optional string csharp_namespace = 37;
  434. // By default Swift generators will take the proto package and CamelCase it
  435. // replacing '.' with underscore and use that to prefix the types/symbols
  436. // defined. When this options is provided, they will use this value instead
  437. // to prefix the types/symbols defined.
  438. optional string swift_prefix = 39;
  439. // Sets the php class prefix which is prepended to all php generated classes
  440. // from this .proto. Default is empty.
  441. optional string php_class_prefix = 40;
  442. // Use this option to change the namespace of php generated classes. Default
  443. // is empty. When this option is empty, the package name will be used for
  444. // determining the namespace.
  445. optional string php_namespace = 41;
  446. // Use this option to change the namespace of php generated metadata classes.
  447. // Default is empty. When this option is empty, the proto file name will be
  448. // used for determining the namespace.
  449. optional string php_metadata_namespace = 44;
  450. // Use this option to change the package of ruby generated classes. Default
  451. // is empty. When this option is not set, the package name will be used for
  452. // determining the ruby package.
  453. optional string ruby_package = 45;
  454. // Any features defined in the specific edition.
  455. optional FeatureSet features = 50;
  456. // The parser stores options it doesn't recognize here.
  457. // See the documentation for the "Options" section above.
  458. repeated UninterpretedOption uninterpreted_option = 999;
  459. // Clients can define custom options in extensions of this message.
  460. // See the documentation for the "Options" section above.
  461. extensions 1000 to max;
  462. reserved 38;
  463. }
  464. message MessageOptions {
  465. // Set true to use the old proto1 MessageSet wire format for extensions.
  466. // This is provided for backwards-compatibility with the MessageSet wire
  467. // format. You should not use this for any other reason: It's less
  468. // efficient, has fewer features, and is more complicated.
  469. //
  470. // The message must be defined exactly as follows:
  471. // message Foo {
  472. // option message_set_wire_format = true;
  473. // extensions 4 to max;
  474. // }
  475. // Note that the message cannot have any defined fields; MessageSets only
  476. // have extensions.
  477. //
  478. // All extensions of your type must be singular messages; e.g. they cannot
  479. // be int32s, enums, or repeated messages.
  480. //
  481. // Because this is an option, the above two restrictions are not enforced by
  482. // the protocol compiler.
  483. optional bool message_set_wire_format = 1 [default = false];
  484. // Disables the generation of the standard "descriptor()" accessor, which can
  485. // conflict with a field of the same name. This is meant to make migration
  486. // from proto1 easier; new code should avoid fields named "descriptor".
  487. optional bool no_standard_descriptor_accessor = 2 [default = false];
  488. // Is this message deprecated?
  489. // Depending on the target platform, this can emit Deprecated annotations
  490. // for the message, or it will be completely ignored; in the very least,
  491. // this is a formalization for deprecating messages.
  492. optional bool deprecated = 3 [default = false];
  493. reserved 4, 5, 6;
  494. // Whether the message is an automatically generated map entry type for the
  495. // maps field.
  496. //
  497. // For maps fields:
  498. // map<KeyType, ValueType> map_field = 1;
  499. // The parsed descriptor looks like:
  500. // message MapFieldEntry {
  501. // option map_entry = true;
  502. // optional KeyType key = 1;
  503. // optional ValueType value = 2;
  504. // }
  505. // repeated MapFieldEntry map_field = 1;
  506. //
  507. // Implementations may choose not to generate the map_entry=true message, but
  508. // use a native map in the target language to hold the keys and values.
  509. // The reflection APIs in such implementations still need to work as
  510. // if the field is a repeated message field.
  511. //
  512. // NOTE: Do not set the option in .proto files. Always use the maps syntax
  513. // instead. The option should only be implicitly set by the proto compiler
  514. // parser.
  515. optional bool map_entry = 7;
  516. reserved 8; // javalite_serializable
  517. reserved 9; // javanano_as_lite
  518. // Enable the legacy handling of JSON field name conflicts. This lowercases
  519. // and strips underscored from the fields before comparison in proto3 only.
  520. // The new behavior takes `json_name` into account and applies to proto2 as
  521. // well.
  522. //
  523. // This should only be used as a temporary measure against broken builds due
  524. // to the change in behavior for JSON field name conflicts.
  525. //
  526. // TODO This is legacy behavior we plan to remove once downstream
  527. // teams have had time to migrate.
  528. optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
  529. // Any features defined in the specific edition.
  530. optional FeatureSet features = 12;
  531. // The parser stores options it doesn't recognize here. See above.
  532. repeated UninterpretedOption uninterpreted_option = 999;
  533. // Clients can define custom options in extensions of this message. See above.
  534. extensions 1000 to max;
  535. }
  536. message FieldOptions {
  537. // NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead.
  538. // The ctype option instructs the C++ code generator to use a different
  539. // representation of the field than it normally would. See the specific
  540. // options below. This option is only implemented to support use of
  541. // [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
  542. // type "bytes" in the open source release.
  543. // TODO: make ctype actually deprecated.
  544. optional CType ctype = 1 [/*deprecated = true,*/ default = STRING];
  545. enum CType {
  546. // Default mode.
  547. STRING = 0;
  548. // The option [ctype=CORD] may be applied to a non-repeated field of type
  549. // "bytes". It indicates that in C++, the data should be stored in a Cord
  550. // instead of a string. For very large strings, this may reduce memory
  551. // fragmentation. It may also allow better performance when parsing from a
  552. // Cord, or when parsing with aliasing enabled, as the parsed Cord may then
  553. // alias the original buffer.
  554. CORD = 1;
  555. STRING_PIECE = 2;
  556. }
  557. // The packed option can be enabled for repeated primitive fields to enable
  558. // a more efficient representation on the wire. Rather than repeatedly
  559. // writing the tag and type for each element, the entire array is encoded as
  560. // a single length-delimited blob. In proto3, only explicit setting it to
  561. // false will avoid using packed encoding. This option is prohibited in
  562. // Editions, but the `repeated_field_encoding` feature can be used to control
  563. // the behavior.
  564. optional bool packed = 2;
  565. // The jstype option determines the JavaScript type used for values of the
  566. // field. The option is permitted only for 64 bit integral and fixed types
  567. // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
  568. // is represented as JavaScript string, which avoids loss of precision that
  569. // can happen when a large value is converted to a floating point JavaScript.
  570. // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
  571. // use the JavaScript "number" type. The behavior of the default option
  572. // JS_NORMAL is implementation dependent.
  573. //
  574. // This option is an enum to permit additional types to be added, e.g.
  575. // goog.math.Integer.
  576. optional JSType jstype = 6 [default = JS_NORMAL];
  577. enum JSType {
  578. // Use the default type.
  579. JS_NORMAL = 0;
  580. // Use JavaScript strings.
  581. JS_STRING = 1;
  582. // Use JavaScript numbers.
  583. JS_NUMBER = 2;
  584. }
  585. // Should this field be parsed lazily? Lazy applies only to message-type
  586. // fields. It means that when the outer message is initially parsed, the
  587. // inner message's contents will not be parsed but instead stored in encoded
  588. // form. The inner message will actually be parsed when it is first accessed.
  589. //
  590. // This is only a hint. Implementations are free to choose whether to use
  591. // eager or lazy parsing regardless of the value of this option. However,
  592. // setting this option true suggests that the protocol author believes that
  593. // using lazy parsing on this field is worth the additional bookkeeping
  594. // overhead typically needed to implement it.
  595. //
  596. // This option does not affect the public interface of any generated code;
  597. // all method signatures remain the same. Furthermore, thread-safety of the
  598. // interface is not affected by this option; const methods remain safe to
  599. // call from multiple threads concurrently, while non-const methods continue
  600. // to require exclusive access.
  601. //
  602. // Note that lazy message fields are still eagerly verified to check
  603. // ill-formed wireformat or missing required fields. Calling IsInitialized()
  604. // on the outer message would fail if the inner message has missing required
  605. // fields. Failed verification would result in parsing failure (except when
  606. // uninitialized messages are acceptable).
  607. optional bool lazy = 5 [default = false];
  608. // unverified_lazy does no correctness checks on the byte stream. This should
  609. // only be used where lazy with verification is prohibitive for performance
  610. // reasons.
  611. optional bool unverified_lazy = 15 [default = false];
  612. // Is this field deprecated?
  613. // Depending on the target platform, this can emit Deprecated annotations
  614. // for accessors, or it will be completely ignored; in the very least, this
  615. // is a formalization for deprecating fields.
  616. optional bool deprecated = 3 [default = false];
  617. // For Google-internal migration only. Do not use.
  618. optional bool weak = 10 [default = false];
  619. // Indicate that the field value should not be printed out when using debug
  620. // formats, e.g. when the field contains sensitive credentials.
  621. optional bool debug_redact = 16 [default = false];
  622. // If set to RETENTION_SOURCE, the option will be omitted from the binary.
  623. enum OptionRetention {
  624. RETENTION_UNKNOWN = 0;
  625. RETENTION_RUNTIME = 1;
  626. RETENTION_SOURCE = 2;
  627. }
  628. optional OptionRetention retention = 17;
  629. // This indicates the types of entities that the field may apply to when used
  630. // as an option. If it is unset, then the field may be freely used as an
  631. // option on any kind of entity.
  632. enum OptionTargetType {
  633. TARGET_TYPE_UNKNOWN = 0;
  634. TARGET_TYPE_FILE = 1;
  635. TARGET_TYPE_EXTENSION_RANGE = 2;
  636. TARGET_TYPE_MESSAGE = 3;
  637. TARGET_TYPE_FIELD = 4;
  638. TARGET_TYPE_ONEOF = 5;
  639. TARGET_TYPE_ENUM = 6;
  640. TARGET_TYPE_ENUM_ENTRY = 7;
  641. TARGET_TYPE_SERVICE = 8;
  642. TARGET_TYPE_METHOD = 9;
  643. }
  644. repeated OptionTargetType targets = 19;
  645. message EditionDefault {
  646. optional Edition edition = 3;
  647. optional string value = 2; // Textproto value.
  648. }
  649. repeated EditionDefault edition_defaults = 20;
  650. // Any features defined in the specific edition.
  651. optional FeatureSet features = 21;
  652. // Information about the support window of a feature.
  653. message FeatureSupport {
  654. // The edition that this feature was first available in. In editions
  655. // earlier than this one, the default assigned to EDITION_LEGACY will be
  656. // used, and proto files will not be able to override it.
  657. optional Edition edition_introduced = 1;
  658. // The edition this feature becomes deprecated in. Using this after this
  659. // edition may trigger warnings.
  660. optional Edition edition_deprecated = 2;
  661. // The deprecation warning text if this feature is used after the edition it
  662. // was marked deprecated in.
  663. optional string deprecation_warning = 3;
  664. // The edition this feature is no longer available in. In editions after
  665. // this one, the last default assigned will be used, and proto files will
  666. // not be able to override it.
  667. optional Edition edition_removed = 4;
  668. }
  669. optional FeatureSupport feature_support = 22;
  670. // The parser stores options it doesn't recognize here. See above.
  671. repeated UninterpretedOption uninterpreted_option = 999;
  672. // Clients can define custom options in extensions of this message. See above.
  673. extensions 1000 to max;
  674. reserved 4; // removed jtype
  675. reserved 18; // reserve target, target_obsolete_do_not_use
  676. }
  677. message OneofOptions {
  678. // Any features defined in the specific edition.
  679. optional FeatureSet features = 1;
  680. // The parser stores options it doesn't recognize here. See above.
  681. repeated UninterpretedOption uninterpreted_option = 999;
  682. // Clients can define custom options in extensions of this message. See above.
  683. extensions 1000 to max;
  684. }
  685. message EnumOptions {
  686. // Set this option to true to allow mapping different tag names to the same
  687. // value.
  688. optional bool allow_alias = 2;
  689. // Is this enum deprecated?
  690. // Depending on the target platform, this can emit Deprecated annotations
  691. // for the enum, or it will be completely ignored; in the very least, this
  692. // is a formalization for deprecating enums.
  693. optional bool deprecated = 3 [default = false];
  694. reserved 5; // javanano_as_lite
  695. // Enable the legacy handling of JSON field name conflicts. This lowercases
  696. // and strips underscored from the fields before comparison in proto3 only.
  697. // The new behavior takes `json_name` into account and applies to proto2 as
  698. // well.
  699. // TODO Remove this legacy behavior once downstream teams have
  700. // had time to migrate.
  701. optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
  702. // Any features defined in the specific edition.
  703. optional FeatureSet features = 7;
  704. // The parser stores options it doesn't recognize here. See above.
  705. repeated UninterpretedOption uninterpreted_option = 999;
  706. // Clients can define custom options in extensions of this message. See above.
  707. extensions 1000 to max;
  708. }
  709. message EnumValueOptions {
  710. // Is this enum value deprecated?
  711. // Depending on the target platform, this can emit Deprecated annotations
  712. // for the enum value, or it will be completely ignored; in the very least,
  713. // this is a formalization for deprecating enum values.
  714. optional bool deprecated = 1 [default = false];
  715. // Any features defined in the specific edition.
  716. optional FeatureSet features = 2;
  717. // Indicate that fields annotated with this enum value should not be printed
  718. // out when using debug formats, e.g. when the field contains sensitive
  719. // credentials.
  720. optional bool debug_redact = 3 [default = false];
  721. // Information about the support window of a feature value.
  722. optional FieldOptions.FeatureSupport feature_support = 4;
  723. // The parser stores options it doesn't recognize here. See above.
  724. repeated UninterpretedOption uninterpreted_option = 999;
  725. // Clients can define custom options in extensions of this message. See above.
  726. extensions 1000 to max;
  727. }
  728. message ServiceOptions {
  729. // Any features defined in the specific edition.
  730. optional FeatureSet features = 34;
  731. // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
  732. // framework. We apologize for hoarding these numbers to ourselves, but
  733. // we were already using them long before we decided to release Protocol
  734. // Buffers.
  735. // Is this service deprecated?
  736. // Depending on the target platform, this can emit Deprecated annotations
  737. // for the service, or it will be completely ignored; in the very least,
  738. // this is a formalization for deprecating services.
  739. optional bool deprecated = 33 [default = false];
  740. // The parser stores options it doesn't recognize here. See above.
  741. repeated UninterpretedOption uninterpreted_option = 999;
  742. // Clients can define custom options in extensions of this message. See above.
  743. extensions 1000 to max;
  744. }
  745. message MethodOptions {
  746. // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
  747. // framework. We apologize for hoarding these numbers to ourselves, but
  748. // we were already using them long before we decided to release Protocol
  749. // Buffers.
  750. // Is this method deprecated?
  751. // Depending on the target platform, this can emit Deprecated annotations
  752. // for the method, or it will be completely ignored; in the very least,
  753. // this is a formalization for deprecating methods.
  754. optional bool deprecated = 33 [default = false];
  755. // Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
  756. // or neither? HTTP based RPC implementation may choose GET verb for safe
  757. // methods, and PUT verb for idempotent methods instead of the default POST.
  758. enum IdempotencyLevel {
  759. IDEMPOTENCY_UNKNOWN = 0;
  760. NO_SIDE_EFFECTS = 1; // implies idempotent
  761. IDEMPOTENT = 2; // idempotent, but may have side effects
  762. }
  763. optional IdempotencyLevel idempotency_level = 34
  764. [default = IDEMPOTENCY_UNKNOWN];
  765. // Any features defined in the specific edition.
  766. optional FeatureSet features = 35;
  767. // The parser stores options it doesn't recognize here. See above.
  768. repeated UninterpretedOption uninterpreted_option = 999;
  769. // Clients can define custom options in extensions of this message. See above.
  770. extensions 1000 to max;
  771. }
  772. // A message representing a option the parser does not recognize. This only
  773. // appears in options protos created by the compiler::Parser class.
  774. // DescriptorPool resolves these when building Descriptor objects. Therefore,
  775. // options protos in descriptor objects (e.g. returned by Descriptor::options(),
  776. // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
  777. // in them.
  778. message UninterpretedOption {
  779. // The name of the uninterpreted option. Each string represents a segment in
  780. // a dot-separated name. is_extension is true iff a segment represents an
  781. // extension (denoted with parentheses in options specs in .proto files).
  782. // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents
  783. // "foo.(bar.baz).moo".
  784. message NamePart {
  785. required string name_part = 1;
  786. required bool is_extension = 2;
  787. }
  788. repeated NamePart name = 2;
  789. // The value of the uninterpreted option, in whatever type the tokenizer
  790. // identified it as during parsing. Exactly one of these should be set.
  791. optional string identifier_value = 3;
  792. optional uint64 positive_int_value = 4;
  793. optional int64 negative_int_value = 5;
  794. optional double double_value = 6;
  795. optional bytes string_value = 7;
  796. optional string aggregate_value = 8;
  797. }
  798. // ===================================================================
  799. // Features
  800. // TODO Enums in C++ gencode (and potentially other languages) are
  801. // not well scoped. This means that each of the feature enums below can clash
  802. // with each other. The short names we've chosen maximize call-site
  803. // readability, but leave us very open to this scenario. A future feature will
  804. // be designed and implemented to handle this, hopefully before we ever hit a
  805. // conflict here.
  806. message FeatureSet {
  807. enum FieldPresence {
  808. FIELD_PRESENCE_UNKNOWN = 0;
  809. EXPLICIT = 1;
  810. IMPLICIT = 2;
  811. LEGACY_REQUIRED = 3;
  812. }
  813. optional FieldPresence field_presence = 1 [
  814. retention = RETENTION_RUNTIME,
  815. targets = TARGET_TYPE_FIELD,
  816. targets = TARGET_TYPE_FILE,
  817. feature_support = {
  818. edition_introduced: EDITION_2023,
  819. },
  820. edition_defaults = { edition: EDITION_LEGACY, value: "EXPLICIT" },
  821. edition_defaults = { edition: EDITION_PROTO3, value: "IMPLICIT" },
  822. edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" }
  823. ];
  824. enum EnumType {
  825. ENUM_TYPE_UNKNOWN = 0;
  826. OPEN = 1;
  827. CLOSED = 2;
  828. }
  829. optional EnumType enum_type = 2 [
  830. retention = RETENTION_RUNTIME,
  831. targets = TARGET_TYPE_ENUM,
  832. targets = TARGET_TYPE_FILE,
  833. feature_support = {
  834. edition_introduced: EDITION_2023,
  835. },
  836. edition_defaults = { edition: EDITION_LEGACY, value: "CLOSED" },
  837. edition_defaults = { edition: EDITION_PROTO3, value: "OPEN" }
  838. ];
  839. enum RepeatedFieldEncoding {
  840. REPEATED_FIELD_ENCODING_UNKNOWN = 0;
  841. PACKED = 1;
  842. EXPANDED = 2;
  843. }
  844. optional RepeatedFieldEncoding repeated_field_encoding = 3 [
  845. retention = RETENTION_RUNTIME,
  846. targets = TARGET_TYPE_FIELD,
  847. targets = TARGET_TYPE_FILE,
  848. feature_support = {
  849. edition_introduced: EDITION_2023,
  850. },
  851. edition_defaults = { edition: EDITION_LEGACY, value: "EXPANDED" },
  852. edition_defaults = { edition: EDITION_PROTO3, value: "PACKED" }
  853. ];
  854. enum Utf8Validation {
  855. UTF8_VALIDATION_UNKNOWN = 0;
  856. VERIFY = 2;
  857. NONE = 3;
  858. reserved 1;
  859. }
  860. optional Utf8Validation utf8_validation = 4 [
  861. retention = RETENTION_RUNTIME,
  862. targets = TARGET_TYPE_FIELD,
  863. targets = TARGET_TYPE_FILE,
  864. feature_support = {
  865. edition_introduced: EDITION_2023,
  866. },
  867. edition_defaults = { edition: EDITION_LEGACY, value: "NONE" },
  868. edition_defaults = { edition: EDITION_PROTO3, value: "VERIFY" }
  869. ];
  870. enum MessageEncoding {
  871. MESSAGE_ENCODING_UNKNOWN = 0;
  872. LENGTH_PREFIXED = 1;
  873. DELIMITED = 2;
  874. }
  875. optional MessageEncoding message_encoding = 5 [
  876. retention = RETENTION_RUNTIME,
  877. targets = TARGET_TYPE_FIELD,
  878. targets = TARGET_TYPE_FILE,
  879. feature_support = {
  880. edition_introduced: EDITION_2023,
  881. },
  882. edition_defaults = { edition: EDITION_LEGACY, value: "LENGTH_PREFIXED" }
  883. ];
  884. enum JsonFormat {
  885. JSON_FORMAT_UNKNOWN = 0;
  886. ALLOW = 1;
  887. LEGACY_BEST_EFFORT = 2;
  888. }
  889. optional JsonFormat json_format = 6 [
  890. retention = RETENTION_RUNTIME,
  891. targets = TARGET_TYPE_MESSAGE,
  892. targets = TARGET_TYPE_ENUM,
  893. targets = TARGET_TYPE_FILE,
  894. feature_support = {
  895. edition_introduced: EDITION_2023,
  896. },
  897. edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY_BEST_EFFORT" },
  898. edition_defaults = { edition: EDITION_PROTO3, value: "ALLOW" }
  899. ];
  900. reserved 999;
  901. extensions 1000 to 9994 [
  902. declaration = {
  903. number: 1000,
  904. full_name: ".pb.cpp",
  905. type: ".pb.CppFeatures"
  906. },
  907. declaration = {
  908. number: 1001,
  909. full_name: ".pb.java",
  910. type: ".pb.JavaFeatures"
  911. },
  912. declaration = { number: 1002, full_name: ".pb.go", type: ".pb.GoFeatures" },
  913. declaration = {
  914. number: 9990,
  915. full_name: ".pb.proto1",
  916. type: ".pb.Proto1Features"
  917. }
  918. ];
  919. extensions 9995 to 9999; // For internal testing
  920. extensions 10000; // for https://github.com/bufbuild/protobuf-es
  921. }
  922. // A compiled specification for the defaults of a set of features. These
  923. // messages are generated from FeatureSet extensions and can be used to seed
  924. // feature resolution. The resolution with this object becomes a simple search
  925. // for the closest matching edition, followed by proto merges.
  926. message FeatureSetDefaults {
  927. // A map from every known edition with a unique set of defaults to its
  928. // defaults. Not all editions may be contained here. For a given edition,
  929. // the defaults at the closest matching edition ordered at or before it should
  930. // be used. This field must be in strict ascending order by edition.
  931. message FeatureSetEditionDefault {
  932. optional Edition edition = 3;
  933. // Defaults of features that can be overridden in this edition.
  934. optional FeatureSet overridable_features = 4;
  935. // Defaults of features that can't be overridden in this edition.
  936. optional FeatureSet fixed_features = 5;
  937. reserved 1, 2;
  938. reserved "features";
  939. }
  940. repeated FeatureSetEditionDefault defaults = 1;
  941. // The minimum supported edition (inclusive) when this was constructed.
  942. // Editions before this will not have defaults.
  943. optional Edition minimum_edition = 4;
  944. // The maximum known edition (inclusive) when this was constructed. Editions
  945. // after this will not have reliable defaults.
  946. optional Edition maximum_edition = 5;
  947. }
  948. // ===================================================================
  949. // Optional source code info
  950. // Encapsulates information about the original source file from which a
  951. // FileDescriptorProto was generated.
  952. message SourceCodeInfo {
  953. // A Location identifies a piece of source code in a .proto file which
  954. // corresponds to a particular definition. This information is intended
  955. // to be useful to IDEs, code indexers, documentation generators, and similar
  956. // tools.
  957. //
  958. // For example, say we have a file like:
  959. // message Foo {
  960. // optional string foo = 1;
  961. // }
  962. // Let's look at just the field definition:
  963. // optional string foo = 1;
  964. // ^ ^^ ^^ ^ ^^^
  965. // a bc de f ghi
  966. // We have the following locations:
  967. // span path represents
  968. // [a,i) [ 4, 0, 2, 0 ] The whole field definition.
  969. // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
  970. // [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
  971. // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
  972. // [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
  973. //
  974. // Notes:
  975. // - A location may refer to a repeated field itself (i.e. not to any
  976. // particular index within it). This is used whenever a set of elements are
  977. // logically enclosed in a single code segment. For example, an entire
  978. // extend block (possibly containing multiple extension definitions) will
  979. // have an outer location whose path refers to the "extensions" repeated
  980. // field without an index.
  981. // - Multiple locations may have the same path. This happens when a single
  982. // logical declaration is spread out across multiple places. The most
  983. // obvious example is the "extend" block again -- there may be multiple
  984. // extend blocks in the same scope, each of which will have the same path.
  985. // - A location's span is not always a subset of its parent's span. For
  986. // example, the "extendee" of an extension declaration appears at the
  987. // beginning of the "extend" block and is shared by all extensions within
  988. // the block.
  989. // - Just because a location's span is a subset of some other location's span
  990. // does not mean that it is a descendant. For example, a "group" defines
  991. // both a type and a field in a single declaration. Thus, the locations
  992. // corresponding to the type and field and their components will overlap.
  993. // - Code which tries to interpret locations should probably be designed to
  994. // ignore those that it doesn't understand, as more types of locations could
  995. // be recorded in the future.
  996. repeated Location location = 1;
  997. message Location {
  998. // Identifies which part of the FileDescriptorProto was defined at this
  999. // location.
  1000. //
  1001. // Each element is a field number or an index. They form a path from
  1002. // the root FileDescriptorProto to the place where the definition appears.
  1003. // For example, this path:
  1004. // [ 4, 3, 2, 7, 1 ]
  1005. // refers to:
  1006. // file.message_type(3) // 4, 3
  1007. // .field(7) // 2, 7
  1008. // .name() // 1
  1009. // This is because FileDescriptorProto.message_type has field number 4:
  1010. // repeated DescriptorProto message_type = 4;
  1011. // and DescriptorProto.field has field number 2:
  1012. // repeated FieldDescriptorProto field = 2;
  1013. // and FieldDescriptorProto.name has field number 1:
  1014. // optional string name = 1;
  1015. //
  1016. // Thus, the above path gives the location of a field name. If we removed
  1017. // the last element:
  1018. // [ 4, 3, 2, 7 ]
  1019. // this path refers to the whole field declaration (from the beginning
  1020. // of the label to the terminating semicolon).
  1021. repeated int32 path = 1 [packed = true];
  1022. // Always has exactly three or four elements: start line, start column,
  1023. // end line (optional, otherwise assumed same as start line), end column.
  1024. // These are packed into a single field for efficiency. Note that line
  1025. // and column numbers are zero-based -- typically you will want to add
  1026. // 1 to each before displaying to a user.
  1027. repeated int32 span = 2 [packed = true];
  1028. // If this SourceCodeInfo represents a complete declaration, these are any
  1029. // comments appearing before and after the declaration which appear to be
  1030. // attached to the declaration.
  1031. //
  1032. // A series of line comments appearing on consecutive lines, with no other
  1033. // tokens appearing on those lines, will be treated as a single comment.
  1034. //
  1035. // leading_detached_comments will keep paragraphs of comments that appear
  1036. // before (but not connected to) the current element. Each paragraph,
  1037. // separated by empty lines, will be one comment element in the repeated
  1038. // field.
  1039. //
  1040. // Only the comment content is provided; comment markers (e.g. //) are
  1041. // stripped out. For block comments, leading whitespace and an asterisk
  1042. // will be stripped from the beginning of each line other than the first.
  1043. // Newlines are included in the output.
  1044. //
  1045. // Examples:
  1046. //
  1047. // optional int32 foo = 1; // Comment attached to foo.
  1048. // // Comment attached to bar.
  1049. // optional int32 bar = 2;
  1050. //
  1051. // optional string baz = 3;
  1052. // // Comment attached to baz.
  1053. // // Another line attached to baz.
  1054. //
  1055. // // Comment attached to moo.
  1056. // //
  1057. // // Another line attached to moo.
  1058. // optional double moo = 4;
  1059. //
  1060. // // Detached comment for corge. This is not leading or trailing comments
  1061. // // to moo or corge because there are blank lines separating it from
  1062. // // both.
  1063. //
  1064. // // Detached comment for corge paragraph 2.
  1065. //
  1066. // optional string corge = 5;
  1067. // /* Block comment attached
  1068. // * to corge. Leading asterisks
  1069. // * will be removed. */
  1070. // /* Block comment attached to
  1071. // * grault. */
  1072. // optional int32 grault = 6;
  1073. //
  1074. // // ignored detached comments.
  1075. optional string leading_comments = 3;
  1076. optional string trailing_comments = 4;
  1077. repeated string leading_detached_comments = 6;
  1078. }
  1079. }
  1080. // Describes the relationship between generated code and its original source
  1081. // file. A GeneratedCodeInfo message is associated with only one generated
  1082. // source file, but may contain references to different source .proto files.
  1083. message GeneratedCodeInfo {
  1084. // An Annotation connects some span of text in generated code to an element
  1085. // of its generating .proto file.
  1086. repeated Annotation annotation = 1;
  1087. message Annotation {
  1088. // Identifies the element in the original source .proto file. This field
  1089. // is formatted the same as SourceCodeInfo.Location.path.
  1090. repeated int32 path = 1 [packed = true];
  1091. // Identifies the filesystem path to the original source .proto.
  1092. optional string source_file = 2;
  1093. // Identifies the starting offset in bytes in the generated code
  1094. // that relates to the identified object.
  1095. optional int32 begin = 3;
  1096. // Identifies the ending offset in bytes in the generated code that
  1097. // relates to the identified object. The end offset should be one past
  1098. // the last relevant byte (so the length of the text = end - begin).
  1099. optional int32 end = 4;
  1100. // Represents the identified object's effect on the element in the original
  1101. // .proto file.
  1102. enum Semantic {
  1103. // There is no effect or the effect is indescribable.
  1104. NONE = 0;
  1105. // The element is set or otherwise mutated.
  1106. SET = 1;
  1107. // An alias to the element is returned.
  1108. ALIAS = 2;
  1109. }
  1110. optional Semantic semantic = 5;
  1111. }
  1112. }