Documentation ¶
Index ¶
- Constants
- Variables
- func IsArrayType(typeName string) bool
- func IsMapType(typeName string) bool
- func IsSliceOrArrayType(typeName string) bool
- func IsSliceType(typeName string) bool
- func IsSpecBuildIn(typeName string) bool
- type AstMeta
- type ExtraNode
- type LeafNode
- type TopNode
- func (topNode *TopNode) AfterInsertExtraNode(parentWalkPath, varName string, extraNode ExtraNode) error
- func (topNode *TopNode) AfterInsertLeafNode(parentWalkPath, varName string, leafNode LeafNode) error
- func (topNode *TopNode) BreadthFirst(ctx context.Context, walkFunc WalkFunc)
- func (topNode *TopNode) DepthCount() int
- func (topNode *TopNode) DepthFirst(ctx context.Context, walkFunc WalkFunc)
- func (topNode *TopNode) FindNode(walkPath string) (targetNode interface{}, ok bool)
- func (topNode *TopNode) FindNodesByFullNames(fullNames []string) (targetNodes []interface{})
- func (topNode *TopNode) FindNodesBySimpleNames(simpleNames []string, simpleFn func(node interface{}) string) (targetNodes []interface{})
- func (topNode *TopNode) NodeCount() int
- func (topNode *TopNode) ReBuildWalkPath()
- type WalkFunc
Constants ¶
View Source
const ( TypeNameMapPrefix = "map[" TypeNameArrayPrefix = "array[" TypeNameSlicePrefix = "slice[" )
Variables ¶
View Source
var AstMetaKey = "xxxxx"
View Source
var (
EmptyTopTree = TopNode{}
)
Functions ¶
func IsArrayType ¶
func IsSliceOrArrayType ¶
func IsSliceType ¶
func IsSpecBuildIn ¶
Types ¶
type AstMeta ¶
type AstMeta struct { VarName string // 声明 SysType string // 系统类型名 FullName string // 全名 RawExpr ast.Expr // array: *ast.ArrayType, map: *ast.MapType, struct: *ast.Ident, it will be nil it cross file struct happen Comment *ast.CommentGroup Doc *ast.CommentGroup CrossModule bool // 是否有可能引用跨模块或者跨文件的类型,只是有可能,并不一定是 }
func NewAstMeta ¶
type ExtraNode ¶
type ExtraNode struct { TypeName string Meta interface{} `json:",omitempty"` LeavesNodes map[string]*LeafNode `json:",omitempty"` // key => varName ExtraNodes map[string]*ExtraNode `json:",omitempty"` // key => varName WalkPath string `json:",omitempty"` }
ExtraNode include type: map, array, struct
func NewExtraNode ¶
type LeafNode ¶
type LeafNode struct { TypeName string Meta interface{} `json:",omitempty"` WalkPath string `json:",omitempty"` }
LeafNode include type: int8,uint8,int16,uint16,int32,uint32,int,int64,uint64,float32,float64,byte,string
func NewLeafNode ¶
type TopNode ¶
type TopNode struct { TypeName string LeavesNodes map[string]*LeafNode `json:",omitempty"` // key => varName ExtraNodes map[string]*ExtraNode `json:",omitempty"` // key => varName Meta interface{} }
TopNode: current only support struct
func NewTopNode ¶
func (*TopNode) AfterInsertExtraNode ¶
func (topNode *TopNode) AfterInsertExtraNode(parentWalkPath, varName string, extraNode ExtraNode) error
Parent Node Must be topNode or ExtraNode
func (*TopNode) AfterInsertLeafNode ¶
func (topNode *TopNode) AfterInsertLeafNode(parentWalkPath, varName string, leafNode LeafNode) error
Parent Node Must be topNode or ExtraNode
func (*TopNode) BreadthFirst ¶
func (*TopNode) DepthCount ¶
func (*TopNode) DepthFirst ¶
func (*TopNode) FindNodesByFullNames ¶
注意map[key]value 和 value 以及 []xxxx 和 xxxx的比较
func (*TopNode) FindNodesBySimpleNames ¶
func (*TopNode) ReBuildWalkPath ¶
func (topNode *TopNode) ReBuildWalkPath()
Click to show internal directories.
Click to hide internal directories.