Documentation ¶
Overview ¶
Package protoparse provides function to parse proto source files and identify the go_api_flag file and message options specified in the files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIInfo ¶
type APIInfo struct { TextRange TextRange HasLeadingComment bool // contains filtered or unexported fields }
APIInfo contains information about an explicit API flag definition.
type FileOpt ¶
type FileOpt struct { // File name containing relative path File string // Proto package name. Package string // Go API level. This can be an implicit value via default. GoAPI gofeaturespb.GoFeatures_APILevel // Whether go_api_flag option is explicitly set in proto file or not. IsExplicit bool // APIInfo is nil if IsExplicit is false. APIInfo *APIInfo // Options of messages defined at the file level. Nested messages are stored // as their children. MessageOpts []*MessageOpt // SourceCodeInfo is set if parsed results includes it. SourceCodeInfo *descpb.SourceCodeInfo // Proto syntax: "proto2", "proto3", "editions", or "editions_go_api_flag". // The latter is set for editions protos that use the old go_api_flag // explicitly. Syntax string }
FileOpt contains the Go API level info for a file along with other proto info.
type MessageOpt ¶
type MessageOpt struct { // Proto message name. Includes parent name if nested, e.g. A.B for message // B that is defined in body of A. Message string // Go API level. This can be an implicit value via file option or in case of // editions features via the parent message. GoAPI gofeaturespb.GoFeatures_APILevel // Whether go_api_flag option is explicitly set in proto message or not. IsExplicit bool // APIInfo is nil if IsExplicit is false. APIInfo *APIInfo // FileDescriptorProto.source_code_info.location.path of this message: // https://github.com/protocolbuffers/protobuf/blob/v29.1/src/google/protobuf/descriptor.proto#L1202 // Example: The 1st nested message of the 6th message in the file is in path // [4, 5, 3, 0]; 4 is the field number of FileDescriptorProto.message_type, 5 // is the index for the 6th message, 3 is DescriptorProto.nested_type, 0 is // the index for the first nested message. LocPath []int32 // Options of the parent message. If this is e.g. the message B which is // defined in the body of message A, then A is the parent. Parent is nil for // messages defined at the file level, i.e. non-nested messages. Parent *MessageOpt // Options of the child messages. If this is e.g. message A and messages // B and C are defined in the body of message A, then B and C are the // children. Children []*MessageOpt }
MessageOpt contains the Go API level info for a message.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses proto source files for go_api_flag values.
func NewParserWithAccessor ¶
func NewParserWithAccessor(acc protoparse.FileAccessor) *Parser
NewParserWithAccessor constructs a Parser with a custom file accessor.
type TextRange ¶
TextRange describes a location in a proto file. Please note that the column indices are code-point indices, not byte indices.
func SpanToTextRange ¶
SpanToTextRange converts a proto2.SourceCodeInfo.Location.span to a TextRange.