descriptor.proto 49 KB

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