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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
type ConverterNode struct {
// contains filtered or unexported fields
}
ConverterNode is a node that represents a converter function.
func (ConverterNode) AssignExpr ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (n ConverterNode) Parent() Node
Parent returns the container of the node or nil.
func (ConverterNode) ReturnsError ¶ added in v0.5.0
func (n ConverterNode) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.
type Copier ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
func NewConverterNode(arg Node, converter *option.FieldConverter) Node
NewConverterNode creates a new ConverterNode.
func NewScalarNode ¶ added in v0.5.0
NewScalarNode creates a new ScalarNode.
func NewStringer ¶ added in v0.5.0
NewStringer creates a new StringerEntry.
type RootNode ¶ added in v0.5.0
type RootNode struct {
// contains filtered or unexported fields
}
RootNode is a special node that represents the root of the expression tree.
func NewRootNode ¶ added in v0.5.0
NewRootNode creates a new RootNode.
func (RootNode) AssignExpr ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
NullCheckExpr returns a value evaluate expression for null check conditional. For example, it returns "dst.Node.Child".
func (RootNode) ObjName ¶ added in v0.5.0
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 ¶ added in v0.5.0
ObjNullable indicates whether the node itself is a pointer type so that it can be nil at runtime.
func (RootNode) ReturnsError ¶ added in v0.5.0
ReturnsError indicates whether the expression returns an error object as the second returning value.
type ScalarNode ¶ added in v0.5.0
type ScalarNode struct {
// contains filtered or unexported fields
}
ScalarNode is a node that represents a leaf element of the expression tree.
func (ScalarNode) AssignExpr ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (n ScalarNode) Parent() Node
Parent returns the container of the node or nil.
func (ScalarNode) ReturnsError ¶ added in v0.5.0
func (n ScalarNode) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.
type StringerEntry ¶ added in v0.5.0
type StringerEntry struct {
// contains filtered or unexported fields
}
StringerEntry is a node that represents a Stringer interface.
func (StringerEntry) AssignExpr ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (e StringerEntry) Parent() Node
Parent returns the container of the node or nil.
func (StringerEntry) ReturnsError ¶ added in v0.5.0
func (e StringerEntry) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.
type StructFieldNode ¶ added in v0.5.0
type StructFieldNode struct {
// contains filtered or unexported fields
}
StructFieldNode represents a struct field.
func NewStructFieldNode ¶ added in v0.5.0
func NewStructFieldNode(container Node, field *types.Var) StructFieldNode
NewStructFieldNode creates a new StructFieldNode.
func (StructFieldNode) AssignExpr ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (n StructFieldNode) Parent() Node
Parent returns the container of the node or nil.
func (StructFieldNode) ReturnsError ¶ added in v0.5.0
func (n StructFieldNode) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.
type StructMethodNode ¶ added in v0.5.0
type StructMethodNode struct {
// contains filtered or unexported fields
}
StructMethodNode represents a struct method.
func NewStructMethodNode ¶ added in v0.5.0
func NewStructMethodNode(container Node, method *types.Func) StructMethodNode
NewStructMethodNode creates a new StructMethodNode.
func (StructMethodNode) AssignExpr ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (n StructMethodNode) Parent() Node
Parent returns the container of the node or nil.
func (StructMethodNode) ReturnsError ¶ added in v0.5.0
func (n StructMethodNode) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.
type TypecastEntry ¶ added in v0.5.0
type TypecastEntry struct {
// contains filtered or unexported fields
}
TypecastEntry is a node that represents a typecast expression.
func (TypecastEntry) AssignExpr ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (n TypecastEntry) Parent() Node
Parent returns the container of the node or nil.
func (TypecastEntry) ReturnsError ¶ added in v0.5.0
func (n TypecastEntry) ReturnsError() bool
ReturnsError indicates whether the expression returns an error object as the second returning value.