func (c FieldPathComponent) RHS() string {
	return gogen.CamelCase(c.Name)
}
RHS returns a right-hand-side expression in go for this field.
package descriptor
import (
	"fmt"
	"strings"
	descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
	gogen "github.com/golang/protobuf/protoc-gen-go/generator"
	"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/httprule"
)
type GoPackage struct {
	Path string
	Name string
	Alias string
}
func (p GoPackage) Standard() bool {
	return !strings.Contains(p.Path, ".")
}
func (p GoPackage) String() string {
	if p.Alias == "" {
		return fmt.Sprintf("%q", p.Path)
	}
	return fmt.Sprintf("%s %q", p.Alias, p.Path)
}
type File struct {
	*descriptor.FileDescriptorProto
	GoPkg GoPackage
	Messages []*Message
	Enums []*Enum
	Services []*Service
}
func (f *File) proto2() bool {
	return f.Syntax == nil || f.GetSyntax() == "proto2"
}
type Message struct {
	File *File
	Outers []string
	*descriptor.DescriptorProto
	Fields []*Field
	Index int
}
func (m *Message) FQMN() string {
	components := []string{""}
	if m.File.Package != nil {
		components = append(components, m.File.GetPackage())
	}
	components = append(components, m.Outers...)
	components = append(components, m.GetName())
	return strings.Join(components, ".")
}
func (m *Message) GoType(currentPackage string) string {
	var components []string
	components = append(components, m.Outers...)
	components = append(components, m.GetName())
	name := strings.Join(components, "_")
	if m.File.GoPkg.Path == currentPackage {
		return name
	}
	pkg := m.File.GoPkg.Name
	if alias := m.File.GoPkg.Alias; alias != "" {
		pkg = alias
	}
	return fmt.Sprintf("%s.%s", pkg, name)
}
type Enum struct {
	File *File
	Outers []string
	*descriptor.EnumDescriptorProto
	Index int
}
func (e *Enum) FQEN() string {
	components := []string{""}
	if e.File.Package != nil {
		components = append(components, e.File.GetPackage())
	}
	components = append(components, e.Outers...)
	components = append(components, e.GetName())
	return strings.Join(components, ".")
}
type Service struct {
	File *File
	*descriptor.ServiceDescriptorProto
	Methods []*Method
}
type Method struct {
	Service *Service
	*descriptor.MethodDescriptorProto
	RequestType *Message
	ResponseType *Message
	Bindings     []*Binding
}
type Binding struct {
	Method *Method
	Index int
	PathTmpl httprule.Template
	HTTPMethod string
	PathParams []Parameter
	Body *Body
}
func (b *Binding) ExplicitParams() []string {
	var result []string
	if b.Body != nil {
		result = append(result, b.Body.FieldPath.String())
	}
	for _, p := range b.PathParams {
		result = append(result, p.FieldPath.String())
	}
	return result
}
type Field struct {
	Message *Message
	FieldMessage *Message
	*descriptor.FieldDescriptorProto
}
type Parameter struct {
	FieldPath
	Target *Field
	Method *Method
}
func (p Parameter) ConvertFuncExpr() (string, error) {
	tbl := proto3ConvertFuncs
	if p.Target.Message.File.proto2() {
		tbl = proto2ConvertFuncs
	}
	typ := p.Target.GetType()
	conv, ok := tbl[typ]
	if !ok {
		return "", fmt.Errorf("unsupported field type %s of parameter %s in %s.%s", typ, p.FieldPath, p.Method.Service.GetName(), p.Method.GetName())
	}
	return conv, nil
}
type Body struct {
	FieldPath FieldPath
}
func (b Body) RHS(msgExpr string) string {
	return b.FieldPath.RHS(msgExpr)
}
type FieldPath []FieldPathComponent
func (p FieldPath) String() string {
	var components []string
	for _, c := range p {
		components = append(components, c.Name)
	}
	return strings.Join(components, ".")
}
func (p FieldPath) IsNestedProto3() bool {
	if len(p) > 1 && !p[0].Target.Message.File.proto2() {
		return true
	}
	return false
}
func (p FieldPath) RHS(msgExpr string) string {
	l := len(p)
	if l == 0 {
		return msgExpr
	}
	components := []string{msgExpr}
	for i, c := range p {
		if i == l-1 {
			components = append(components, c.RHS())
			continue
		}
		components = append(components, c.LHS())
	}
	return strings.Join(components, ".")
}
type FieldPathComponent struct {
	Name string
	Target *Field
}