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