retag

package
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelCase

func CamelCase(s string) string

CamelCase returns the CamelCased name. If there is an interior underscore followed by a lower case letter, drop the underscore and convert the letter to upper case. There is a remote possibility of this rewrite causing a name collision, but it's so remote we're prepared to pretend it's nonexistent - since the C++ generator lowercases names, it's extremely unlikely to have two fields with different capitalizations. In short, _my_field_name_2 becomes XMyFieldName_2.

func CamelCaseSlice

func CamelCaseSlice(elem []string) string

CamelCaseSlice is like CamelCase, but the argument is a slice of strings to be joined with "_".

func PrintComment

func PrintComment(file *ast.File)

func Rewrite

func Rewrite(g *protogen.Plugin)

Types

type FieldInfo

type FieldInfo struct {
	FieldNameInProto string
	FieldNameInGo    string
	FieldTag         reflect.StructTag
	UpdateStrategy   pb.FieldTag_UpdateStrategy
}

type FileInfo

type FileInfo struct {
	FileName    string
	StructInfos []StructInfo
}

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(protoFiles []FileInfo, protoGenerator *protogen.Plugin) *Generator

func (*Generator) Generate

func (g *Generator) Generate()

Generate produces the rewrite content to proto's Generator.

func (*Generator) ParseGoContent

func (g *Generator) ParseGoContent(outerFile *pluginpb.CodeGeneratorResponse_File)

ParseGoContent analyzes the single package constructed from the patterns and tags. ParseGoContent exits if there is an error.

type GoFile

type GoFile struct {
	// contains filtered or unexported fields
}

GoFile holds a single parsed astFile and associated data.

func (*GoFile) FoundProtoMessage

func (g *GoFile) FoundProtoMessage(typ string) (StructInfo, bool)

type StructInfo

type StructInfo struct {
	StructNameInProto string
	StructNameInGo    string
	FieldInfos        []FieldInfo
}

func WalkDescriptorProto

func WalkDescriptorProto(g *protogen.Plugin, dp *descriptorpb.DescriptorProto, typeNames []string) []StructInfo

WalkDescriptorProto returns all struct infos of dp, which contains FieldTag.

func (*StructInfo) FindField

func (si *StructInfo) FindField(name string) (FieldInfo, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL