Documentation ¶
Index ¶
- Constants
- func CreatePrefixList(pkg string) []string
- func GetMaxTag(isMessageSet bool) int32
- func GetProto3Optional(fd *dpb.FieldDescriptorProto) bool
- func InitCap(name string) string
- func JsonName(name string) string
- func PopulateSourceInfoMap(fd *dpb.FileDescriptorProto, m SourceInfoMap)
- func ProcessProto3OptionalFields(msgd *dpb.DescriptorProto)
- func RecomputeSourceInfo(c SourceInfoComputer)
- func SetProto3Optional(fd *dpb.FieldDescriptorProto)
- type SourceInfoComputeFunc
- type SourceInfoComputer
- type SourceInfoMap
- func (m SourceInfoMap) Add(path []int32, loc *dpb.SourceCodeInfo_Location)
- func (m SourceInfoMap) Get(path []int32) *dpb.SourceCodeInfo_Location
- func (m SourceInfoMap) GetAll(path []int32) []*dpb.SourceCodeInfo_Location
- func (m SourceInfoMap) PutIfAbsent(path []int32, loc *dpb.SourceCodeInfo_Location) bool
Constants ¶
const ( // MaxNormalTag is the maximum allowed tag number for a field in a normal message. MaxNormalTag = 536870911 // 2^29 - 1 // MaxMessageSetTag is the maximum allowed tag number of a field in a message that // uses the message set wire format. MaxMessageSetTag = math.MaxInt32 - 1 // MaxTag is the maximum allowed tag number. (It is the same as MaxMessageSetTag // since that is the absolute highest allowed.) MaxTag = MaxMessageSetTag // SpecialReservedStart is the first tag in a range that is reserved and not // allowed for use in message definitions. SpecialReservedStart = 19000 // SpecialReservedEnd is the last tag in a range that is reserved and not // allowed for use in message definitions. SpecialReservedEnd = 19999 // File_packageTag is the tag number of the package element in a file // descriptor proto. File_packageTag = 2 // File_dependencyTag is the tag number of the dependencies element in a // file descriptor proto. File_dependencyTag = 3 // File_messagesTag is the tag number of the messages element in a file // descriptor proto. File_messagesTag = 4 // File_enumsTag is the tag number of the enums element in a file descriptor // proto. File_enumsTag = 5 // File_servicesTag is the tag number of the services element in a file // descriptor proto. File_servicesTag = 6 // File_extensionsTag is the tag number of the extensions element in a file // descriptor proto. File_extensionsTag = 7 // File_optionsTag is the tag number of the options element in a file // descriptor proto. File_optionsTag = 8 // File_syntaxTag is the tag number of the syntax element in a file // descriptor proto. File_syntaxTag = 12 // Message_nameTag is the tag number of the name element in a message // descriptor proto. Message_nameTag = 1 // Message_fieldsTag is the tag number of the fields element in a message // descriptor proto. Message_fieldsTag = 2 // Message_nestedMessagesTag is the tag number of the nested messages // element in a message descriptor proto. Message_nestedMessagesTag = 3 // Message_enumsTag is the tag number of the enums element in a message // descriptor proto. Message_enumsTag = 4 // Message_extensionRangeTag is the tag number of the extension ranges // element in a message descriptor proto. Message_extensionRangeTag = 5 // Message_extensionsTag is the tag number of the extensions element in a // message descriptor proto. Message_extensionsTag = 6 // Message_optionsTag is the tag number of the options element in a message // descriptor proto. Message_optionsTag = 7 // Message_oneOfsTag is the tag number of the one-ofs element in a message // descriptor proto. Message_oneOfsTag = 8 // Message_reservedRangeTag is the tag number of the reserved ranges element // in a message descriptor proto. Message_reservedRangeTag = 9 // Message_reservedNameTag is the tag number of the reserved names element // in a message descriptor proto. Message_reservedNameTag = 10 // ExtensionRange_startTag is the tag number of the start index in an // extension range proto. ExtensionRange_startTag = 1 // ExtensionRange_endTag is the tag number of the end index in an // extension range proto. ExtensionRange_endTag = 2 // ExtensionRange_optionsTag is the tag number of the options element in an // extension range proto. ExtensionRange_optionsTag = 3 // ReservedRange_startTag is the tag number of the start index in a reserved // range proto. ReservedRange_startTag = 1 // ReservedRange_endTag is the tag number of the end index in a reserved // range proto. ReservedRange_endTag = 2 // Field_nameTag is the tag number of the name element in a field descriptor // proto. Field_nameTag = 1 // Field_extendeeTag is the tag number of the extendee element in a field // descriptor proto. Field_extendeeTag = 2 // Field_numberTag is the tag number of the number element in a field // descriptor proto. Field_numberTag = 3 // Field_labelTag is the tag number of the label element in a field // descriptor proto. Field_labelTag = 4 // Field_typeTag is the tag number of the type element in a field descriptor // proto. Field_typeTag = 5 // Field_typeNameTag is the tag number of the type name element in a field // descriptor proto. Field_typeNameTag = 6 // Field_defaultTag is the tag number of the default value element in a // field descriptor proto. Field_defaultTag = 7 // Field_optionsTag is the tag number of the options element in a field // descriptor proto. Field_optionsTag = 8 // Field_jsonNameTag is the tag number of the JSON name element in a field // descriptor proto. Field_jsonNameTag = 10 // Field_proto3OptionalTag is the tag number of the proto3_optional element // in a descriptor proto. Field_proto3OptionalTag = 17 // OneOf_nameTag is the tag number of the name element in a one-of // descriptor proto. OneOf_nameTag = 1 // OneOf_optionsTag is the tag number of the options element in a one-of // descriptor proto. OneOf_optionsTag = 2 // Enum_nameTag is the tag number of the name element in an enum descriptor // proto. Enum_nameTag = 1 // Enum_valuesTag is the tag number of the values element in an enum // descriptor proto. Enum_valuesTag = 2 // Enum_optionsTag is the tag number of the options element in an enum // descriptor proto. Enum_optionsTag = 3 // Enum_reservedRangeTag is the tag number of the reserved ranges element in // an enum descriptor proto. Enum_reservedRangeTag = 4 // Enum_reservedNameTag is the tag number of the reserved names element in // an enum descriptor proto. Enum_reservedNameTag = 5 // EnumVal_nameTag is the tag number of the name element in an enum value // descriptor proto. EnumVal_nameTag = 1 // EnumVal_numberTag is the tag number of the number element in an enum // value descriptor proto. EnumVal_numberTag = 2 // EnumVal_optionsTag is the tag number of the options element in an enum // value descriptor proto. EnumVal_optionsTag = 3 // Service_nameTag is the tag number of the name element in a service // descriptor proto. Service_nameTag = 1 // Service_methodsTag is the tag number of the methods element in a service // descriptor proto. Service_methodsTag = 2 // Service_optionsTag is the tag number of the options element in a service // descriptor proto. Service_optionsTag = 3 // Method_nameTag is the tag number of the name element in a method // descriptor proto. Method_nameTag = 1 // Method_inputTag is the tag number of the input type element in a method // descriptor proto. Method_inputTag = 2 // Method_outputTag is the tag number of the output type element in a method // descriptor proto. Method_outputTag = 3 // Method_optionsTag is the tag number of the options element in a method // descriptor proto. Method_optionsTag = 4 // Method_inputStreamTag is the tag number of the input stream flag in a // method descriptor proto. Method_inputStreamTag = 5 // Method_outputStreamTag is the tag number of the output stream flag in a // method descriptor proto. Method_outputStreamTag = 6 // UninterpretedOptionsTag is the tag number of the uninterpreted options // element. All *Options messages use the same tag for the field that stores // uninterpreted options. UninterpretedOptionsTag = 999 // Uninterpreted_nameTag is the tag number of the name element in an // uninterpreted options proto. Uninterpreted_nameTag = 2 // Uninterpreted_identTag is the tag number of the identifier value in an // uninterpreted options proto. Uninterpreted_identTag = 3 // Uninterpreted_posIntTag is the tag number of the positive int value in an // uninterpreted options proto. Uninterpreted_posIntTag = 4 // Uninterpreted_negIntTag is the tag number of the negative int value in an // uninterpreted options proto. Uninterpreted_negIntTag = 5 // Uninterpreted_doubleTag is the tag number of the double value in an // uninterpreted options proto. Uninterpreted_doubleTag = 6 // Uninterpreted_stringTag is the tag number of the string value in an // uninterpreted options proto. Uninterpreted_stringTag = 7 // Uninterpreted_aggregateTag is the tag number of the aggregate value in an // uninterpreted options proto. Uninterpreted_aggregateTag = 8 // UninterpretedName_nameTag is the tag number of the name element in an // uninterpreted option name proto. UninterpretedName_nameTag = 1 )
Variables ¶
This section is empty.
Functions ¶
func CreatePrefixList ¶
CreatePrefixList returns a list of package prefixes to search when resolving a symbol name. If the given package is blank, it returns only the empty string. If the given package contains only one token, e.g. "foo", it returns that token and the empty string, e.g. ["foo", ""]. Otherwise, it returns successively shorter prefixes of the package and then the empty string. For example, for a package named "foo.bar.baz" it will return the following list:
["foo.bar.baz", "foo.bar", "foo", ""]
func GetMaxTag ¶
GetMaxTag returns the max tag number allowed, based on whether a message uses message set wire format or not.
func GetProto3Optional ¶
func GetProto3Optional(fd *dpb.FieldDescriptorProto) bool
func PopulateSourceInfoMap ¶
func PopulateSourceInfoMap(fd *dpb.FileDescriptorProto, m SourceInfoMap)
PopulateSourceInfoMap populates the given SourceInfoMap with information from the given file descriptor.
func ProcessProto3OptionalFields ¶
func ProcessProto3OptionalFields(msgd *dpb.DescriptorProto)
ProcessProto3OptionalFields adds synthetic oneofs to the given message descriptor for each proto3 optional field. It also updates the fields to have the correct oneof index reference.
func RecomputeSourceInfo ¶
func RecomputeSourceInfo(c SourceInfoComputer)
RecomputeSourceInfo is used to initiate recomputation of source info. This is is used by the protoparse package, after it interprets options.
func SetProto3Optional ¶
func SetProto3Optional(fd *dpb.FieldDescriptorProto)
Types ¶
type SourceInfoComputeFunc ¶
type SourceInfoComputeFunc func()
SourceInfoComputeFunc is the type that a desc.Descriptor will embed. It will be aliased in the desc package to an unexported name so it is not marked as an exported field in reflection and not present in Go docs.
type SourceInfoComputer ¶
type SourceInfoComputer interface {
// contains filtered or unexported methods
}
SourceInfoComputer is a single method which will be invoked to recompute source info. This is needed for the protoparse package, which needs to link descriptors without source info in order to interpret options, but then needs to re-compute source info after that interpretation so that final linked descriptors expose the right info.
type SourceInfoMap ¶
type SourceInfoMap map[string][]*dpb.SourceCodeInfo_Location
SourceInfoMap is a map of paths in a descriptor to the corresponding source code info.
func CreateSourceInfoMap ¶
func CreateSourceInfoMap(fd *dpb.FileDescriptorProto) SourceInfoMap
CreateSourceInfoMap constructs a new SourceInfoMap and populates it with the source code info in the given file descriptor proto.
func (SourceInfoMap) Add ¶
func (m SourceInfoMap) Add(path []int32, loc *dpb.SourceCodeInfo_Location)
Add stores the given source code info for the given path.
func (SourceInfoMap) Get ¶
func (m SourceInfoMap) Get(path []int32) *dpb.SourceCodeInfo_Location
Get returns the source code info for the given path. If there are multiple locations for the same path, the first one is returned.
func (SourceInfoMap) GetAll ¶
func (m SourceInfoMap) GetAll(path []int32) []*dpb.SourceCodeInfo_Location
GetAll returns all source code info for the given path.
func (SourceInfoMap) PutIfAbsent ¶
func (m SourceInfoMap) PutIfAbsent(path []int32, loc *dpb.SourceCodeInfo_Location) bool
PutIfAbsent stores the given source code info for the given path only if the given path does not exist in the map. This method returns true when the value is stored, false if the path already exists.