codegen

package
v0.0.0-...-deefee7 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckEnvironments

func CheckEnvironments() (err error)

func GenPbFile

func GenPbFile(pb *PbPackage) error

func GenerateEditorconfig

func GenerateEditorconfig(pb *PbPackage) (err error)

func GenerateMod

func GenerateMod(pb *PbPackage) (err error)

func GenerateProto

func GenerateProto(pb *PbPackage) error

func GetDefaultEditorconfig

func GetDefaultEditorconfig() []byte

func InjectTagParseFile

func InjectTagParseFile(inputPath string) ([]textArea, error)

func InjectTagWriteFile

func InjectTagWriteFile(inputPath string, areas []textArea) error

func ParseGoDir

func ParseGoDir(dir string) (map[string]*GoPackage, error)

Types

type GoContext

type GoContext struct {
	GoPathList          []string
	ModPath2RealPathMap map[string]string
	ModPath2ModNameMap  map[string]string
}

func (*GoContext) FindPackageName

func (ctx *GoContext) FindPackageName(modPath string) string

func (*GoContext) FindPackagePath

func (ctx *GoContext) FindPackagePath(modPath string) string

type GoFile

type GoFile struct {
	Imports []*GoImport
	Funcs   []*GoFunc
	Structs []*GoStruct
}

func ParseGoFile

func ParseGoFile(filePath string) (*GoFile, error)

type GoFunc

type GoFunc struct {
	Name      string
	FuncCalls []*GoFuncCall

	Returns []*GoReturn
	Params  []*GoParams

	// 接收类型,struct的类型
	RecvType string
}

func (*GoFunc) Clone

func (p *GoFunc) Clone() *GoFunc

func (*GoFunc) String

func (p *GoFunc) String() string

func (*GoFunc) StringWithColor

func (p *GoFunc) StringWithColor() string

type GoFuncCall

type GoFuncCall struct {
	Names []string
	Args  []*GoFuncCallArg
}

type GoFuncCallArg

type GoFuncCallArg struct {
	Names []string
}

type GoFuncNode

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

func (*GoFuncNode) GetFile

func (g *GoFuncNode) GetFile() *GoFile

func (*GoFuncNode) GetFunc

func (g *GoFuncNode) GetFunc() *GoFunc

type GoImport

type GoImport struct {
	Name string
	Path string
}

type GoPackage

type GoPackage struct {
	Name    string
	FileMap map[string]*GoFile
	FuncMap map[string]*GoFuncNode
}

func (*GoPackage) GetFunc

func (p *GoPackage) GetFunc(name string) *GoFuncNode

type GoParams

type GoParams struct {
	TypeName  string
	FieldName string

	// typename == func
	GoFunc *GoFunc
}

func (*GoParams) String

func (p *GoParams) String() string

func (*GoParams) StringWithColor

func (p *GoParams) StringWithColor() string

type GoReturn

type GoReturn struct {
	Name string
}

func (*GoReturn) String

func (p *GoReturn) String() string

func (*GoReturn) StringWithColor

func (p *GoReturn) StringWithColor() string

type GoStruct

type GoStruct struct {
	Name string
}

type PbComment

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

func NewPbComment

func NewPbComment(c *proto.Comment) *PbComment

func (*PbComment) Comment

func (p *PbComment) Comment() *proto.Comment

type PbCommentTag

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

func NewPbCommentTag

func NewPbCommentTag(tag string) *PbCommentTag

func (*PbCommentTag) Lines

func (p *PbCommentTag) Lines() []string

func (*PbCommentTag) Tag

func (p *PbCommentTag) Tag() string

type PbEnum

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

type PbEnumField

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

func NewPbEnumField

func NewPbEnumField(f *proto.EnumField) *PbEnumField

type PbMapField

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

func NewPbMapField

func NewPbMapField(f *proto.MapField) *PbMapField

type PbMessage

type PbMessage struct {
	Name string
	// contains filtered or unexported fields
}

func NewPbMessage

func NewPbMessage(m *proto.Message) *PbMessage

func (*PbMessage) Message

func (p *PbMessage) Message() *proto.Message

type PbNormalField

type PbNormalField struct {
	Name string
	// contains filtered or unexported fields
}

func NewPbNormalField

func NewPbNormalField(f *proto.NormalField) *PbNormalField

func (*PbNormalField) Field

func (p *PbNormalField) Field() *proto.NormalField

func (*PbNormalField) Type

func (p *PbNormalField) Type() string

type PbOption

type PbOption struct {
	Name  string
	Value string
	// contains filtered or unexported fields
}

func NewPbOption

func NewPbOption(o *proto.Option) *PbOption

type PbPackage

type PbPackage struct {
	RawGoPackage string
	PackageName  string
	// contains filtered or unexported fields
}

func NewPbPackage

func NewPbPackage(protoFilePath string, p *proto.Proto) *PbPackage

func ParseProto

func ParseProto(path string) (*PbPackage, error)

func (*PbPackage) GetMessageFullName

func (p *PbPackage) GetMessageFullName(e *proto.Message) string

func (*PbPackage) GetParent

func (p *PbPackage) GetParent(v proto.Visitee) string

func (*PbPackage) GoPackage

func (p *PbPackage) GoPackage() string

func (*PbPackage) ProjectRoot

func (p *PbPackage) ProjectRoot() string

func (*PbPackage) Proto

func (p *PbPackage) Proto() *proto.Proto

func (*PbPackage) ProtoFilePath

func (p *PbPackage) ProtoFilePath() string

func (*PbPackage) Walk

func (p *PbPackage) Walk()

type PbRPC

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

type ProtoVisitor

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

func (*ProtoVisitor) VisitComment

func (p *ProtoVisitor) VisitComment(e *proto.Comment)

func (*ProtoVisitor) VisitEnum

func (p *ProtoVisitor) VisitEnum(e *proto.Enum)

func (*ProtoVisitor) VisitEnumField

func (p *ProtoVisitor) VisitEnumField(i *proto.EnumField)

func (*ProtoVisitor) VisitExtensions

func (p *ProtoVisitor) VisitExtensions(e *proto.Extensions)

func (*ProtoVisitor) VisitGroup

func (p *ProtoVisitor) VisitGroup(g *proto.Group)

func (*ProtoVisitor) VisitImport

func (p *ProtoVisitor) VisitImport(i *proto.Import)

func (*ProtoVisitor) VisitMapField

func (p *ProtoVisitor) VisitMapField(f *proto.MapField)

func (*ProtoVisitor) VisitMessage

func (p *ProtoVisitor) VisitMessage(m *proto.Message)

func (*ProtoVisitor) VisitNormalField

func (p *ProtoVisitor) VisitNormalField(i *proto.NormalField)

func (*ProtoVisitor) VisitOneof

func (p *ProtoVisitor) VisitOneof(o *proto.Oneof)

func (*ProtoVisitor) VisitOneofField

func (p *ProtoVisitor) VisitOneofField(o *proto.OneOfField)

func (*ProtoVisitor) VisitOption

func (p *ProtoVisitor) VisitOption(o *proto.Option)

func (*ProtoVisitor) VisitOptions

func (p *ProtoVisitor) VisitOptions(o *proto.Option)

func (*ProtoVisitor) VisitPackage

func (p *ProtoVisitor) VisitPackage(pkg *proto.Package)

func (*ProtoVisitor) VisitProto

func (p *ProtoVisitor) VisitProto(*proto.Proto)

func (*ProtoVisitor) VisitRPC

func (p *ProtoVisitor) VisitRPC(rpc *proto.RPC)

func (*ProtoVisitor) VisitReserved

func (p *ProtoVisitor) VisitReserved(rs *proto.Reserved)

func (*ProtoVisitor) VisitService

func (p *ProtoVisitor) VisitService(v *proto.Service)

func (*ProtoVisitor) VisitSyntax

func (p *ProtoVisitor) VisitSyntax(s *proto.Syntax)

type ScanErrCodeContext

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

func NewScanErrCodeContext

func NewScanErrCodeContext() *ScanErrCodeContext

func (*ScanErrCodeContext) GetErrListAndClear

func (p *ScanErrCodeContext) GetErrListAndClear() []string

func (*ScanErrCodeContext) GetModList

func (p *ScanErrCodeContext) GetModList() []string

func (*ScanErrCodeContext) MergePkgMap

func (p *ScanErrCodeContext) MergePkgMap(m map[string]*GoPackage)

func (*ScanErrCodeContext) MergePkgMapWithPkgName

func (p *ScanErrCodeContext) MergePkgMapWithPkgName(m map[string]*GoPackage, pkg string)

func (*ScanErrCodeContext) Scan

func (p *ScanErrCodeContext) Scan(mod, name string)

Jump to

Keyboard shortcuts

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