kubernetes/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser.go

func rewriteFile(name string, header []byte, rewriteFn func(*token.FileSet, *ast.File) error) error {}

type ExtractFunc

type OptionalFunc

func RewriteGeneratedGogoProtobufFile(name string, extractFn ExtractFunc, optionalFn OptionalFunc, header []byte) error {}

// rewriteOptionalMethods makes specific mutations to marshaller methods that belong to types identified
// as being "optional" (they may be nil on the wire). This allows protobuf to serialize a map or slice and
// properly discriminate between empty and nil (which is not possible in protobuf).
// TODO: move into upstream gogo-protobuf once https://github.com/gogo/protobuf/issues/181
// has agreement
func rewriteOptionalMethods(decl ast.Decl, isOptional OptionalFunc) {}

type optionalAssignmentVisitor

// Visit walks the provided node, transforming field initializations of the form
// m.Field = &OptionalType{} -> m.Field = OptionalType{}
func (v optionalAssignmentVisitor) Visit(n ast.Node) ast.Visitor {}

type optionalItemsVisitor

// Visit walks the provided node, looking for specific patterns to transform that match
// the effective outcome of turning struct{ map[x]y || []x } into map[x]y or []x.
func (v *optionalItemsVisitor) Visit(n ast.Node) ast.Visitor {}

func isFieldSelector(n ast.Expr, name, field string) bool {}

func isIdent(n ast.Expr, value string) bool {}

func receiver(f *ast.FuncDecl) (ident *ast.Ident, pointer bool, ok bool) {}

// dropExistingTypeDeclarations removes any type declaration for which extractFn returns true. The function
// returns true if the entire declaration should be dropped.
func dropExistingTypeDeclarations(decl ast.Decl, extractFn ExtractFunc) bool {}

// dropEmptyImportDeclarations strips any generated but no-op imports from the generated code
// to prevent generation from being able to define side-effects.  The function returns true
// if the entire declaration should be dropped.
func dropEmptyImportDeclarations(decl ast.Decl) bool {}

func RewriteTypesWithProtobufStructTags(name string, structTags map[string]map[string]string) error {}

func getFieldName(expr ast.Expr, structname string) (name string, err error) {}

func updateStructTags(decl ast.Decl, structTags map[string]map[string]string, toCopy []string) []error {}