internal

package
v0.0.0-...-849e097 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenInputType

func GenInputType(arg *Statement, fn *mapper.Func) *Statement

func GenInputValue

func GenInputValue(fn *mapper.Func) *Statement

func GenReturnType

func GenReturnType(fn *mapper.Func) *Statement

func GenReturnValue

func GenReturnValue(fn *mapper.Func) *Statement

func GenType

func GenType(T types.Type) *jen.Statement

GenType generates the basic type.

func GenTypeName

func GenTypeName(T types.Type) *jen.Statement

GenTypeName generates the element type.

func GenerateInputType

func GenerateInputType(T types.Type, variadic bool) *Statement

func GenerateOutputType

func GenerateOutputType(T types.Type, hasError bool) *Statement

func GenerateType

func GenerateType(T types.Type) *Statement

func PrettyError

func PrettyError(msg string, args ...interface{}) error

func PrettyFuncSignature

func PrettyFuncSignature(fn *types.Func) string

Types

type Assignment

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

func NewAssignment

func NewAssignment(fieldPrefix, fieldName0, fieldNameN string, method bool) *Assignment

func (*Assignment) Increment

func (a *Assignment) Increment()

func (*Assignment) Lhs

func (a *Assignment) Lhs() *jen.Statement

func (*Assignment) Rhs

func (a *Assignment) Rhs() *jen.Statement

NOTE: For scenario with similar alias.

type ProductMapper interface {
	ProductToProductSummary(Products) (*ProductSummary, error)
}
type Products struct {
	Items []int64
}

// Both are referring to items.

type ProductSummary struct {
	Items      bool  `map:",IsValidStatus"`
	TotalCount int64 `map:"Items,CountItems"`
}

type FieldResolver

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

func NewFieldResolver

func NewFieldResolver(name string, lhs, rhs mapper.StructField) *FieldResolver

func (*FieldResolver) Assign

func (f *FieldResolver) Assign()

func (FieldResolver) IsField

func (f FieldResolver) IsField() bool

func (FieldResolver) IsMethod

func (f FieldResolver) IsMethod() bool

func (FieldResolver) Lhs

func (f FieldResolver) Lhs() interface{}

func (FieldResolver) LhsType

func (f FieldResolver) LhsType() *jen.Statement

func (FieldResolver) LhsVar

func (f FieldResolver) LhsVar() *jen.Statement

func (FieldResolver) Rhs

func (FieldResolver) RhsType

func (f FieldResolver) RhsType() *jen.Statement

func (FieldResolver) RhsVar

func (f FieldResolver) RhsVar() *jen.Statement

func (FieldResolver) Tag

func (f FieldResolver) Tag() *mapper.Tag

type FuncBuilder

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

FuncBuilder builds local functions in a function scope.

func NewFuncBuilder

func NewFuncBuilder(r Resolver, fn *mapper.Func) *FuncBuilder

NewFuncBuilder returns a pointer for FuncBuilder.

func (*FuncBuilder) BuildFuncCall

func (b *FuncBuilder) BuildFuncCall(fn *mapper.Func, lhs, rhs types.Type) *Statement

func (*FuncBuilder) BuildMethodCall

func (b *FuncBuilder) BuildMethodCall(prefix *Statement, fn *mapper.Func, lhs, rhs types.Type) *Statement

func (*FuncBuilder) GenReturnOnError

func (b *FuncBuilder) GenReturnOnError() *Statement

func (*FuncBuilder) GenReturnType

func (b *FuncBuilder) GenReturnType() *Statement

type FuncParamVisitor

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

func NewFuncParamVisitor

func NewFuncParamVisitor() *FuncParamVisitor

func (FuncParamVisitor) FieldByName

func (v FuncParamVisitor) FieldByName(name string) (mapper.StructField, bool)

func (FuncParamVisitor) HasError

func (v FuncParamVisitor) HasError() bool

HasError returns true if the LHS field is method call and returns error as the result tuple.

func (FuncParamVisitor) MethodByName

func (v FuncParamVisitor) MethodByName(name string) (*mapper.Func, bool)

func (*FuncParamVisitor) Visit

func (v *FuncParamVisitor) Visit(T types.Type) bool

type FuncResultVisitor

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

func NewFuncResultVisitor

func NewFuncResultVisitor() *FuncResultVisitor

func (FuncResultVisitor) FieldByName

func (v FuncResultVisitor) FieldByName(name string) (mapper.StructField, bool)

func (FuncResultVisitor) Fields

func (v FuncResultVisitor) Fields() []string

func (*FuncResultVisitor) HasError

func (v *FuncResultVisitor) HasError() bool

func (FuncResultVisitor) MapperByTag

func (v FuncResultVisitor) MapperByTag(tag string) (*mapper.Func, bool)

func (*FuncResultVisitor) Visit

func (v *FuncResultVisitor) Visit(T types.Type) bool

type FuncVisitor

type FuncVisitor struct {
	Param  *FuncParamVisitor
	Result *FuncResultVisitor
}

func (FuncVisitor) HasError

func (f FuncVisitor) HasError() bool

func (*FuncVisitor) Visit

func (f *FuncVisitor) Visit(fn *types.Func)

type InputTypeVisitor

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

func NewInputTypeVisitor

func NewInputTypeVisitor(variadic bool) *InputTypeVisitor

func (*InputTypeVisitor) Visit

func (v *InputTypeVisitor) Visit(T types.Type) bool

type InterfaceVisitor

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

func NewInterfaceVisitor

func NewInterfaceVisitor(T types.Type) *InterfaceVisitor

func (*InterfaceVisitor) MethodInfo

func (v *InterfaceVisitor) MethodInfo(name string) (*FuncVisitor, bool)

func (*InterfaceVisitor) Methods

func (v *InterfaceVisitor) Methods() map[string]*mapper.Func

func (*InterfaceVisitor) Visit

func (v *InterfaceVisitor) Visit(T types.Type) bool

type MethodResolver

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

func NewMethodResolver

func NewMethodResolver(name string, lhs *mapper.Func, rhs mapper.StructField) *MethodResolver

func (*MethodResolver) Assign

func (f *MethodResolver) Assign()

func (MethodResolver) IsField

func (f MethodResolver) IsField() bool

func (MethodResolver) IsMethod

func (f MethodResolver) IsMethod() bool

func (MethodResolver) Lhs

func (f MethodResolver) Lhs() interface{}

func (MethodResolver) LhsType

func (f MethodResolver) LhsType() *jen.Statement

func (MethodResolver) LhsVar

func (f MethodResolver) LhsVar() *jen.Statement

func (MethodResolver) Rhs

func (MethodResolver) RhsType

func (f MethodResolver) RhsType() *jen.Statement

func (MethodResolver) RhsVar

func (f MethodResolver) RhsVar() *jen.Statement

func (MethodResolver) Tag

func (f MethodResolver) Tag() *mapper.Tag

type Multi

type Multi []*jen.Statement

func NewMulti

func NewMulti(code ...*jen.Statement) *Multi

func (*Multi) Add

func (m *Multi) Add(code ...*jen.Statement) *Multi

func (*Multi) Statement

func (m *Multi) Statement() *jen.Statement

type OutputTypeVisitor

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

func NewOutputTypeVisitor

func NewOutputTypeVisitor() *OutputTypeVisitor

func (*OutputTypeVisitor) Visit

func (v *OutputTypeVisitor) Visit(T types.Type) bool

type Resolver

type Resolver interface {
	LhsVar() *jen.Statement
	RhsVar() *jen.Statement

	Lhs() interface{}
	Rhs() mapper.StructField

	LhsType() *jen.Statement
	RhsType() *jen.Statement

	Tag() *mapper.Tag

	// Increases the assignment count
	Assign()

	IsField() bool
	IsMethod() bool
}

Resolver ...

type TypeVisitor

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

func NewTypeVisitor

func NewTypeVisitor() *TypeVisitor

func (*TypeVisitor) Visit

func (v *TypeVisitor) Visit(T types.Type) bool

Jump to

Keyboard shortcuts

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