Documentation ¶
Index ¶
- func IsRecursive(node Node, typ types.Type) bool
- func IterateStructFields(structNode Node, cb func(Node) (done bool))
- func IterateStructMethods(structNode Node, cb func(Node) (done bool))
- type ConverterNode
- func (n ConverterNode) AssignExpr() string
- func (n ConverterNode) ExprType() types.Type
- func (n ConverterNode) MatcherExpr() string
- func (n ConverterNode) NullCheckExpr() string
- func (n ConverterNode) ObjName() string
- func (n ConverterNode) ObjNullable() bool
- func (n ConverterNode) Parent() Node
- func (n ConverterNode) ReturnsError() bool
- type Copier
- type MethodEntry
- type MethodsInfo
- type Node
- type RootNode
- type ScalarNode
- func (n ScalarNode) AssignExpr() string
- func (n ScalarNode) ExprType() types.Type
- func (n ScalarNode) MatcherExpr() string
- func (n ScalarNode) NullCheckExpr() string
- func (n ScalarNode) ObjName() string
- func (n ScalarNode) ObjNullable() bool
- func (n ScalarNode) Parent() Node
- func (n ScalarNode) ReturnsError() bool
- type StringerEntry
- func (e StringerEntry) AssignExpr() string
- func (e StringerEntry) ExprType() types.Type
- func (e StringerEntry) MatcherExpr() string
- func (e StringerEntry) NullCheckExpr() string
- func (e StringerEntry) ObjName() string
- func (e StringerEntry) ObjNullable() bool
- func (e StringerEntry) Parent() Node
- func (e StringerEntry) ReturnsError() bool
- type StructFieldNode
- func (n StructFieldNode) AssignExpr() string
- func (n StructFieldNode) ExprType() types.Type
- func (n StructFieldNode) MatcherExpr() string
- func (n StructFieldNode) NullCheckExpr() string
- func (n StructFieldNode) ObjName() string
- func (n StructFieldNode) ObjNullable() bool
- func (n StructFieldNode) Parent() Node
- func (n StructFieldNode) ReturnsError() bool
- type StructMethodNode
- func (n StructMethodNode) AssignExpr() string
- func (n StructMethodNode) ExprType() types.Type
- func (n StructMethodNode) MatcherExpr() string
- func (n StructMethodNode) NullCheckExpr() string
- func (n StructMethodNode) ObjName() string
- func (n StructMethodNode) ObjNullable() bool
- func (n StructMethodNode) Parent() Node
- func (n StructMethodNode) ReturnsError() bool
- type TypecastEntry
- func (n TypecastEntry) AssignExpr() string
- func (n TypecastEntry) ExprType() types.Type
- func (n TypecastEntry) MatcherExpr() string
- func (n TypecastEntry) NullCheckExpr() string
- func (n TypecastEntry) ObjName() string
- func (n TypecastEntry) ObjNullable() bool
- func (n TypecastEntry) Parent() Node
- func (n TypecastEntry) ReturnsError() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRecursive ¶
IsRecursive checks if the given type is the same as any of the ancestor nodes in the tree rooted at the given node. If true, it means there is a recursive reference in the tree.
func IterateStructFields ¶
IterateStructFields iterates through all the fields of the given structNode and calls the given callback function for each one. If the callback function returns true, the iteration stops.
func IterateStructMethods ¶
IterateStructMethods iterates through all the methods of the given structNode and calls the given callback function for each one. Only those methods that comply with the getter compliant method will be processed. If the callback function returns true, the iteration stops.
Types ¶
type ConverterNode ¶
type ConverterNode struct {
// contains filtered or unexported fields
}
ConverterNode is a node that represents a converter function.
func (ConverterNode) AssignExpr ¶
func (n ConverterNode) AssignExpr() string
AssignExpr returns a value evaluate expression for assignment. For example, it returns "dst.User.Name", "dst.User.Status()", "strconv.Itoa(dst.User.Score())", etc.
func (ConverterNode) ExprType ¶
func (n ConverterNode) ExprType() types.Type
ExprType returns the evaluated result type of the node. For example, it returns the type that "dst.User.Status()" returns. An expression may be in converter form, such as "strconv.Itoa(dst.User.Status())".
func (ConverterNode) MatcherExpr ¶
func (n ConverterNode) MatcherExpr() string
MatcherExpr returns a value evaluate expression for assignment but omits the root variable name. For example, it returns "User.Status()" in "dst.User.Status()".
func (ConverterNode) NullCheckExpr ¶
func (n ConverterNode) NullCheckExpr() string
NullCheckExpr returns a value evaluate expression for null check conditional. For example, it returns "dst.Node.Child".
func (ConverterNode) ObjName ¶
func (n ConverterNode) ObjName() string
ObjName returns the ident of the leaf element. For example, it returns "Status" in both of dst.User.Status or dst.User.Status().
func (ConverterNode) ObjNullable ¶
func (n ConverterNode) ObjNullable() bool
ObjNullable indicates whether the node itself is a pointer type so that it can be nil at runtime.
func (ConverterNode) Parent ¶
func (n ConverterNode) Parent() Node
Parent returns the container of the node or nil.
func (ConverterNode) ReturnsError ¶
func (n ConverterNode) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.
type Copier ¶
type Copier struct { IsRoot bool // true means this copier refers the convergen method. false means it becomes an inner function. Name string // name becomes a copier function's name. LHS types.Type RHS types.Type HandleCount int }
Copier contains a helper function information.
type MethodEntry ¶
MethodEntry contains a method information.
func (*MethodEntry) Args ¶
func (m *MethodEntry) Args() []types.Type
Args returns the argument types.
func (*MethodEntry) DstVar ¶
func (m *MethodEntry) DstVar() *types.Var
DstVar returns a variable that is a copy destination. It assumes that there is only one destination variable.
func (*MethodEntry) Results ¶
func (m *MethodEntry) Results() []types.Type
Results returns the result types.
func (*MethodEntry) RetError ¶
func (m *MethodEntry) RetError() bool
RetError returns true if the last result is an error.
func (*MethodEntry) SrcVar ¶
func (m *MethodEntry) SrcVar() *types.Var
SrcVar returns a variable that is a copy source. It assumes that there is only one source variable.
type MethodsInfo ¶
type MethodsInfo struct { Marker string Methods []*MethodEntry }
MethodsInfo contains a list of MethodEntry.
type Node ¶
type Node interface { // Parent returns the container of the node or nil. Parent() Node // ObjName returns the ident of the leaf element. // For example, it returns "Status" in both of dst.User.Status or dst.User.Status(). ObjName() string // ObjNullable indicates whether the node itself is a pointer type so that it can be nil at runtime. ObjNullable() bool // AssignExpr returns a value evaluate expression for assignment. // For example, it returns "dst.User.Name", "dst.User.Status()", "strconv.Itoa(dst.User.Score())", etc. AssignExpr() string // MatcherExpr returns a value evaluate expression for assignment but omits the root variable name. // For example, it returns "User.Status()" in "dst.User.Status()". MatcherExpr() string // NullCheckExpr returns a value evaluate expression for null check conditional. // For example, it returns "dst.Node.Child". NullCheckExpr() string // ExprType returns the evaluated result type of the node. // For example, it returns the type that "dst.User.Status()" returns. // An expression may be in converter form, such as "strconv.Itoa(dst.User.Status())". ExprType() types.Type // ReturnsError indicates whether the expression returns an error object as the second returning value. ReturnsError() bool }
func NewConverterNode ¶
func NewConverterNode(arg Node, converter *option.FieldConverter) Node
NewConverterNode creates a new ConverterNode.
func NewScalarNode ¶
NewScalarNode creates a new ScalarNode.
type RootNode ¶
type RootNode struct {
// contains filtered or unexported fields
}
RootNode is a special node that represents the root of the expression tree.
func NewRootNode ¶
NewRootNode creates a new RootNode.
func (RootNode) AssignExpr ¶
AssignExpr returns a value evaluate expression for assignment. For example, it returns "dst.User.Name", "dst.User.Status()", "strconv.Itoa(dst.User.Score())", etc.
func (RootNode) ExprType ¶
ExprType returns the evaluated result type of the node. For example, it returns the type that "dst.User.Status()" returns. An expression may be in converter form, such as "strconv.Itoa(dst.User.Status())".
func (RootNode) MatcherExpr ¶
MatcherExpr returns a value evaluate expression for assignment but omits the root variable name. For example, it returns "User.Status()" in "dst.User.Status()".
func (RootNode) NullCheckExpr ¶
NullCheckExpr returns a value evaluate expression for null check conditional. For example, it returns "dst.Node.Child".
func (RootNode) ObjName ¶
ObjName returns the ident of the leaf element. For example, it returns "Status" in both of dst.User.Status or dst.User.Status().
func (RootNode) ObjNullable ¶
ObjNullable indicates whether the node itself is a pointer type so that it can be nil at runtime.
func (RootNode) ReturnsError ¶
ReturnsError indicates whether the expression returns an error object as the second returning value.
type ScalarNode ¶
type ScalarNode struct {
// contains filtered or unexported fields
}
ScalarNode is a node that represents a leaf element of the expression tree.
func (ScalarNode) AssignExpr ¶
func (n ScalarNode) AssignExpr() string
AssignExpr returns a value evaluate expression for assignment. For example, it returns "dst.User.Name", "dst.User.Status()", "strconv.Itoa(dst.User.Score())", etc.
func (ScalarNode) ExprType ¶
func (n ScalarNode) ExprType() types.Type
ExprType returns the evaluated result type of the node. For example, it returns the type that "dst.User.Status()" returns. An expression may be in converter form, such as "strconv.Itoa(dst.User.Status())".
func (ScalarNode) MatcherExpr ¶
func (n ScalarNode) MatcherExpr() string
MatcherExpr returns a value evaluate expression for assignment but omits the root variable name. For example, it returns "User.Status()" in "dst.User.Status()".
func (ScalarNode) NullCheckExpr ¶
func (n ScalarNode) NullCheckExpr() string
NullCheckExpr returns a value evaluate expression for null check conditional. For example, it returns "dst.Node.Child".
func (ScalarNode) ObjName ¶
func (n ScalarNode) ObjName() string
ObjName returns the ident of the leaf element. For example, it returns "Status" in both of dst.User.Status or dst.User.Status().
func (ScalarNode) ObjNullable ¶
func (n ScalarNode) ObjNullable() bool
ObjNullable indicates whether the node itself is a pointer type so that it can be nil at runtime.
func (ScalarNode) Parent ¶
func (n ScalarNode) Parent() Node
Parent returns the container of the node or nil.
func (ScalarNode) ReturnsError ¶
func (n ScalarNode) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.
type StringerEntry ¶
type StringerEntry struct {
// contains filtered or unexported fields
}
StringerEntry is a node that represents a Stringer interface.
func (StringerEntry) AssignExpr ¶
func (e StringerEntry) AssignExpr() string
AssignExpr returns a value evaluate expression for assignment. For example, it returns "dst.User.Name", "dst.User.Status()", "strconv.Itoa(dst.User.Score())", etc.
func (StringerEntry) ExprType ¶
func (e StringerEntry) ExprType() types.Type
ExprType returns the evaluated result type of the node. For example, it returns the type that "dst.User.Status()" returns. An expression may be in converter form, such as "strconv.Itoa(dst.User.Status())".
func (StringerEntry) MatcherExpr ¶
func (e StringerEntry) MatcherExpr() string
MatcherExpr returns a value evaluate expression for assignment but omits the root variable name. For example, it returns "User.Status()" in "dst.User.Status()".
func (StringerEntry) NullCheckExpr ¶
func (e StringerEntry) NullCheckExpr() string
NullCheckExpr returns a value evaluate expression for null check conditional. For example, it returns "dst.Node.Child".
func (StringerEntry) ObjName ¶
func (e StringerEntry) ObjName() string
ObjName returns the ident of the leaf element. For example, it returns "Status" in both of dst.User.Status or dst.User.Status().
func (StringerEntry) ObjNullable ¶
func (e StringerEntry) ObjNullable() bool
ObjNullable indicates whether the node itself is a pointer type so that it can be nil at runtime.
func (StringerEntry) Parent ¶
func (e StringerEntry) Parent() Node
Parent returns the container of the node or nil.
func (StringerEntry) ReturnsError ¶
func (e StringerEntry) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.
type StructFieldNode ¶
type StructFieldNode struct {
// contains filtered or unexported fields
}
StructFieldNode represents a struct field.
func NewStructFieldNode ¶
func NewStructFieldNode(container Node, field *types.Var) StructFieldNode
NewStructFieldNode creates a new StructFieldNode.
func (StructFieldNode) AssignExpr ¶
func (n StructFieldNode) AssignExpr() string
AssignExpr returns a value evaluate expression for assignment. For example, it returns "dst.User.Name", "dst.User.Status()", "strconv.Itoa(dst.User.Score())", etc.
func (StructFieldNode) ExprType ¶
func (n StructFieldNode) ExprType() types.Type
ExprType returns the evaluated result type of the node. For example, it returns the type that "dst.User.Status()" returns. An expression may be in converter form, such as "strconv.Itoa(dst.User.Status())".
func (StructFieldNode) MatcherExpr ¶
func (n StructFieldNode) MatcherExpr() string
MatcherExpr returns a value evaluate expression for assignment but omits the root variable name. For example, it returns "User.Status()" in "dst.User.Status()".
func (StructFieldNode) NullCheckExpr ¶
func (n StructFieldNode) NullCheckExpr() string
NullCheckExpr returns a value evaluate expression for null check conditional. For example, it returns "dst.Node.Child".
func (StructFieldNode) ObjName ¶
func (n StructFieldNode) ObjName() string
ObjName returns the ident of the leaf element. For example, it returns "Status" in both of dst.User.Status or dst.User.Status().
func (StructFieldNode) ObjNullable ¶
func (n StructFieldNode) ObjNullable() bool
ObjNullable indicates whether the node itself is a pointer type so that it can be nil at runtime.
func (StructFieldNode) Parent ¶
func (n StructFieldNode) Parent() Node
Parent returns the container of the node or nil.
func (StructFieldNode) ReturnsError ¶
func (n StructFieldNode) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.
type StructMethodNode ¶
type StructMethodNode struct {
// contains filtered or unexported fields
}
StructMethodNode represents a struct method.
func NewStructMethodNode ¶
func NewStructMethodNode(container Node, method *types.Func) StructMethodNode
NewStructMethodNode creates a new StructMethodNode.
func (StructMethodNode) AssignExpr ¶
func (n StructMethodNode) AssignExpr() string
AssignExpr returns a value evaluate expression for assignment. For example, it returns "dst.User.Name", "dst.User.Status()", "strconv.Itoa(dst.User.Score())", etc.
func (StructMethodNode) ExprType ¶
func (n StructMethodNode) ExprType() types.Type
ExprType returns the evaluated result type of the node. For example, it returns the type that "dst.User.Status()" returns. An expression may be in converter form, such as "strconv.Itoa(dst.User.Status())".
func (StructMethodNode) MatcherExpr ¶
func (n StructMethodNode) MatcherExpr() string
MatcherExpr returns a value evaluate expression for assignment but omits the root variable name. For example, it returns "User.Status()" in "dst.User.Status()".
func (StructMethodNode) NullCheckExpr ¶
func (n StructMethodNode) NullCheckExpr() string
NullCheckExpr returns a value evaluate expression for null check conditional. For example, it returns "dst.Node.Child".
func (StructMethodNode) ObjName ¶
func (n StructMethodNode) ObjName() string
ObjName returns the ident of the leaf element. For example, it returns "Status" in both of dst.User.Status or dst.User.Status().
func (StructMethodNode) ObjNullable ¶
func (n StructMethodNode) ObjNullable() bool
ObjNullable indicates whether the node itself is a pointer type so that it can be nil at runtime.
func (StructMethodNode) Parent ¶
func (n StructMethodNode) Parent() Node
Parent returns the container of the node or nil.
func (StructMethodNode) ReturnsError ¶
func (n StructMethodNode) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.
type TypecastEntry ¶
type TypecastEntry struct {
// contains filtered or unexported fields
}
TypecastEntry is a node that represents a typecast expression.
func (TypecastEntry) AssignExpr ¶
func (n TypecastEntry) AssignExpr() string
AssignExpr returns a value evaluate expression for assignment. For example, it returns "dst.User.Name", "dst.User.Status()", "strconv.Itoa(dst.User.Score())", etc.
func (TypecastEntry) ExprType ¶
func (n TypecastEntry) ExprType() types.Type
ExprType returns the evaluated result type of the node. For example, it returns the type that "dst.User.Status()" returns. An expression may be in converter form, such as "strconv.Itoa(dst.User.Status())".
func (TypecastEntry) MatcherExpr ¶
func (n TypecastEntry) MatcherExpr() string
MatcherExpr returns a value evaluate expression for assignment but omits the root variable name. For example, it returns "User.Status()" in "dst.User.Status()".
func (TypecastEntry) NullCheckExpr ¶
func (n TypecastEntry) NullCheckExpr() string
NullCheckExpr returns a value evaluate expression for null check conditional. For example, it returns "dst.Node.Child".
func (TypecastEntry) ObjName ¶
func (n TypecastEntry) ObjName() string
ObjName returns the ident of the leaf element. For example, it returns "Status" in both of dst.User.Status or dst.User.Status().
func (TypecastEntry) ObjNullable ¶
func (n TypecastEntry) ObjNullable() bool
ObjNullable indicates whether the node itself is a pointer type so that it can be nil at runtime.
func (TypecastEntry) Parent ¶
func (n TypecastEntry) Parent() Node
Parent returns the container of the node or nil.
func (TypecastEntry) ReturnsError ¶
func (n TypecastEntry) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.