inspect

package module
v0.0.0-...-8a9bafa Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IsNodeExprIdent          = IsNodeExpr[*ast.Ident]
	IsNodeExprFuncType       = IsNodeExpr[*ast.FuncType]
	IsNodeExprStructType     = IsNodeExpr[*ast.StructType]
	IsNodeExprInterfaceType  = IsNodeExpr[*ast.InterfaceType]
	IsNodeExprArrayType      = IsNodeExpr[*ast.ArrayType]
	IsNodeExprMapType        = IsNodeExpr[*ast.MapType]
	IsNodeExprChanType       = IsNodeExpr[*ast.ChanType]
	IsNodeExprStarExpr       = IsNodeExpr[*ast.StarExpr]
	IsNodeExprSelectorExpr   = IsNodeExpr[*ast.SelectorExpr]
	IsNodeExprBasicLit       = IsNodeExpr[*ast.BasicLit]
	IsNodeExprEllipsis       = IsNodeExpr[*ast.Ellipsis]
	IsNodeExprUnaryExpr      = IsNodeExpr[*ast.UnaryExpr]
	IsNodeExprBinaryExpr     = IsNodeExpr[*ast.BinaryExpr]
	IsNodeExprSliceExpr      = IsNodeExpr[*ast.SliceExpr]
	IsNodeExprIndexExpr      = IsNodeExpr[*ast.IndexExpr]
	IsNodeExprCallExpr       = IsNodeExpr[*ast.CallExpr]
	IsNodeExprTypeAssertExpr = IsNodeExpr[*ast.TypeAssertExpr]
	IsNodeExprKeyValueExpr   = IsNodeExpr[*ast.KeyValueExpr]
	IsNodeExprBadExpr        = IsNodeExpr[*ast.BadExpr]
	IsNodeExprCompositeLit   = IsNodeExpr[*ast.CompositeLit]
	IsNodeExprFuncLit        = IsNodeExpr[*ast.FuncLit]
	IsNodeExprParenExpr      = IsNodeExpr[*ast.ParenExpr]
)
View Source
var (
	IsNodeField       = IsNode[*ast.Field]
	IsNodeValueSpec   = IsNode[*ast.ValueSpec]
	IsNodeTypeSpec    = IsNode[*ast.TypeSpec]
	IsNodeFuncDecl    = IsNode[*ast.FuncDecl]
	IsNodeLabeledStmt = IsNode[*ast.LabeledStmt]
	IsNodeAssignStmt  = IsNode[*ast.AssignStmt]

	IsNodeFieldList = IsNode[*ast.FieldList]

	IsNodeIdent          = IsNode[*ast.Ident]
	IsNodeFuncType       = IsNode[*ast.FuncType]
	IsNodeStructType     = IsNode[*ast.StructType]
	IsNodeInterfaceType  = IsNode[*ast.InterfaceType]
	IsNodeArrayType      = IsNode[*ast.ArrayType]
	IsNodeMapType        = IsNode[*ast.MapType]
	IsNodeChanType       = IsNode[*ast.ChanType]
	IsNodeStarExpr       = IsNode[*ast.StarExpr]
	IsNodeSelectorExpr   = IsNode[*ast.SelectorExpr]
	IsNodeBasicLit       = IsNode[*ast.BasicLit]
	IsNodeEllipsis       = IsNode[*ast.Ellipsis]
	IsNodeUnaryExpr      = IsNode[*ast.UnaryExpr]
	IsNodeBinaryExpr     = IsNode[*ast.BinaryExpr]
	IsNodeSliceExpr      = IsNode[*ast.SliceExpr]
	IsNodeIndexExpr      = IsNode[*ast.IndexExpr]
	IsNodeCallExpr       = IsNode[*ast.CallExpr]
	IsNodeTypeAssertExpr = IsNode[*ast.TypeAssertExpr]
	IsNodeKeyValueExpr   = IsNode[*ast.KeyValueExpr]
	IsNodeBadExpr        = IsNode[*ast.BadExpr]
	IsNodeCompositeLit   = IsNode[*ast.CompositeLit]
	IsNodeFuncLit        = IsNode[*ast.FuncLit]
	IsNodeParenExpr      = IsNode[*ast.ParenExpr]
)
View Source
var (
	IsTypeObjectConst    = IsTypeObject[*types.Const]
	IsTypeObjectFunc     = IsTypeObject[*types.Func]
	IsTypeObjectTypeName = IsTypeObject[*types.TypeName]
	IsTypeObjectVar      = IsTypeObject[*types.Var]

	IsTypeBasic     = IsType[*types.Basic]
	IsTypeMap       = IsType[*types.Map]
	IsTypeArray     = IsType[*types.Array]
	IsTypeStruct    = IsType[*types.Struct]
	IsTypeTuple     = IsType[*types.Tuple]
	IsTypeUnion     = IsType[*types.Union]
	IsTypeSignature = IsType[*types.Signature]
	IsTypeTypeParam = IsType[*types.TypeParam]
	IsTypePointer   = IsType[*types.Pointer]
	IsTypeSlice     = IsType[*types.Slice]
	IsTypeInterface = IsType[*types.Interface]
	IsTypeChan      = IsType[*types.Chan]
	IsTypeNamed     = IsType[*types.Named]
)
View Source
var (
	Debug = false
	Trace = false
)

Functions

func CamelCase

func CamelCase(s string) string

func IsNode

func IsNode[t ast.Node](expr ast.Node) (ok bool)

func IsNodeExpr

func IsNodeExpr[t ast.Expr](expr ast.Expr) (ok bool)

func IsType

func IsType[T types.Type](p types.Type) (ok bool)

func IsTypeObject

func IsTypeObject[T types.Object](p types.Object) (ok bool)

func PascalCase

func PascalCase(s string) string

func TypeObjectVisit

func TypeObjectVisit[X any](pkg *packages.Package, name string, o types.Object, visitor TypeVisitor[*TypeInspector[X], X], withUnexported bool)

func TypeVisit

func TypeVisit[X any](pkg *packages.Package, o types.Object, p types.Type, visitor TypeVisitor[*TypeInspector[X], X], withUnexported bool)

Types

type AstInspector

type AstInspector[X any] struct {
	WithUnexported bool
	Visitor        NodeVisitor[*AstInspector[X], X]
	X              X
	Pkg            *packages.Package
	File           *ast.File
	Object         *ast.Object
}

type BaseInspector

type BaseInspector[T Inspector] struct {
	Parser func(*packages.Config, ...string) ([]*packages.Package, error)

	Inspector T
}

func NewAstInspector

func NewAstInspector[X any](withUnexported bool) *BaseInspector[*AstInspector[X]]

func NewTypeInspector

func NewTypeInspector[X any](withUnexported bool) *BaseInspector[*TypeInspector[X]]

func (*BaseInspector[T]) Inspect

func (s *BaseInspector[T]) Inspect(configure func(*packages.Config), checks func([]*packages.Package) error, patterns ...string) (err error)

type Dir

type Dir int
const (
	ONC Dir = iota
	ENT
	EXT
)

func (Dir) String

func (i Dir) String() string

type Face

type Face struct {
	Pkg       *types.Package
	Name      string
	Interface *types.Interface
}

type FnNodeVisitor

type FnNodeVisitor[I Inspector, X any] struct {
	FnVisitFieldDecl NodeDeclVisit[I, *ast.Field, X]
	FnVisitFuncDecl  NodeDeclVisit[I, *ast.FuncDecl, X]
	FnVisitTypeDecl  NodeDeclVisit[I, *ast.TypeSpec, X]
	FnVisitValueDecl NodeDeclVisit[I, *ast.ValueSpec, X]

	FnVisitFieldList NodeVisit[I, *ast.FieldList, X]
	FnVisitField     NodeVisit[I, *ast.Field, X]

	FnVisitIdent         NodeExprVisit[I, *ast.Ident, X]
	FnVisitFuncType      NodeExprVisit[I, *ast.FuncType, X]
	FnVisitStructType    NodeExprVisit[I, *ast.StructType, X]
	FnVisitInterfaceType NodeExprVisit[I, *ast.InterfaceType, X]
	FnVisitArrayType     NodeExprVisit[I, *ast.ArrayType, X]
	FnVisitMapType       NodeExprVisit[I, *ast.MapType, X]
	FnVisitChanType      NodeExprVisit[I, *ast.ChanType, X]
	FnVisitStarExpr      NodeExprVisit[I, *ast.StarExpr, X]
	FnVisitSelectorExpr  NodeExprVisit[I, *ast.SelectorExpr, X]
	FnVisitBasicLit      NodeExprVisit[I, *ast.BasicLit, X]
	FnVisitEllipsis      NodeExprVisit[I, *ast.Ellipsis, X]
	FnVisitUnaryExpr     NodeExprVisit[I, *ast.UnaryExpr, X]
	FnVisitBinaryExpr    NodeExprVisit[I, *ast.BinaryExpr, X]
}

func (FnNodeVisitor[I, X]) VisitArrayType

func (n FnNodeVisitor[I, X]) VisitArrayType(i I, d Dir, o *ast.Object, x *ast.ArrayType, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitBasicLit

func (n FnNodeVisitor[I, X]) VisitBasicLit(i I, d Dir, o *ast.Object, x *ast.BasicLit, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitBinaryExpr

func (n FnNodeVisitor[I, X]) VisitBinaryExpr(i I, d Dir, o *ast.Object, x *ast.BinaryExpr, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitChanType

func (n FnNodeVisitor[I, X]) VisitChanType(i I, d Dir, o *ast.Object, x *ast.ChanType, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitEllipsis

func (n FnNodeVisitor[I, X]) VisitEllipsis(i I, d Dir, o *ast.Object, x *ast.Ellipsis, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitField

func (n FnNodeVisitor[I, X]) VisitField(i I, d Dir, o *ast.Object, x *ast.Field, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitFieldDecl

func (n FnNodeVisitor[I, X]) VisitFieldDecl(i I, d Dir, name string, o *ast.Object, x *ast.Field, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitFieldList

func (n FnNodeVisitor[I, X]) VisitFieldList(i I, d Dir, o *ast.Object, x *ast.FieldList, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitFuncDecl

func (n FnNodeVisitor[I, X]) VisitFuncDecl(i I, d Dir, name string, o *ast.Object, x *ast.FuncDecl, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitFuncType

func (n FnNodeVisitor[I, X]) VisitFuncType(i I, d Dir, o *ast.Object, x *ast.FuncType, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitIdent

func (n FnNodeVisitor[I, X]) VisitIdent(i I, d Dir, o *ast.Object, x *ast.Ident, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitInterfaceType

func (n FnNodeVisitor[I, X]) VisitInterfaceType(i I, d Dir, o *ast.Object, x *ast.InterfaceType, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitMapType

func (n FnNodeVisitor[I, X]) VisitMapType(i I, d Dir, o *ast.Object, x *ast.MapType, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitSelectorExpr

func (n FnNodeVisitor[I, X]) VisitSelectorExpr(i I, d Dir, o *ast.Object, x *ast.SelectorExpr, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitStarExpr

func (n FnNodeVisitor[I, X]) VisitStarExpr(i I, d Dir, o *ast.Object, x *ast.StarExpr, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitStructType

func (n FnNodeVisitor[I, X]) VisitStructType(i I, d Dir, o *ast.Object, x *ast.StructType, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitTypeDecl

func (n FnNodeVisitor[I, X]) VisitTypeDecl(i I, d Dir, name string, o *ast.Object, x *ast.TypeSpec, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitUnaryExpr

func (n FnNodeVisitor[I, X]) VisitUnaryExpr(i I, d Dir, o *ast.Object, x *ast.UnaryExpr, nodes Nodes, cx X) bool

func (FnNodeVisitor[I, X]) VisitValueDecl

func (n FnNodeVisitor[I, X]) VisitValueDecl(i I, d Dir, name string, o *ast.Object, x *ast.ValueSpec, nodes Nodes, cx X) bool

type FnTypeVisitor

type FnTypeVisitor[I Inspector, X any] struct {
	FnVisitConst    TypeRootVisitor[I, *types.Const, X]
	FnVisitFunc     TypeRootVisitor[I, *types.Func, X]
	FnVisitTypeName TypeRootVisitor[I, *types.TypeName, X]
	FnVisitVar      TypeRootVisitor[I, *types.Var, X]

	FnVisitTypeVar  TypeElementVisitor[I, *types.Var, X]
	FnVisitTypeFunc TypeElementVisitor[I, *types.Func, X]

	FnVisitTypeBasic     TypeElementTypeVisitor[I, *types.Basic, X]
	FnVisitTypeMap       TypeElementTypeVisitor[I, *types.Map, X]
	FnVisitTypeArray     TypeElementTypeVisitor[I, *types.Array, X]
	FnVisitTypeStruct    TypeElementTypeVisitor[I, *types.Struct, X]
	FnVisitTypeTuple     TypeElementTypeVisitor[I, *types.Tuple, X]
	FnVisitTypeUnion     TypeElementTypeVisitor[I, *types.Union, X]
	FnVisitTypeSignature TypeElementTypeVisitor[I, *types.Signature, X]
	FnVisitTypeParam     TypeElementTypeVisitor[I, *types.TypeParam, X]
	FnVisitTypePointer   TypeElementTypeVisitor[I, *types.Pointer, X]
	FnVisitTypeSlice     TypeElementTypeVisitor[I, *types.Slice, X]
	FnVisitTypeInterface TypeElementTypeVisitor[I, *types.Interface, X]
	FnVisitTypeChan      TypeElementTypeVisitor[I, *types.Chan, X]
	FnVisitTypeNamed     TypeElementTypeVisitor[I, *types.Named, X]
}

func (FnTypeVisitor[I, X]) VisitConst

func (t FnTypeVisitor[I, X]) VisitConst(i I, d Dir, name string, e *types.Const, cx X) bool

func (FnTypeVisitor[I, X]) VisitFunc

func (t FnTypeVisitor[I, X]) VisitFunc(i I, d Dir, name string, e *types.Func, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeArray

func (t FnTypeVisitor[I, X]) VisitTypeArray(i I, d Dir, o types.Object, x *types.Array, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeBasic

func (t FnTypeVisitor[I, X]) VisitTypeBasic(i I, d Dir, o types.Object, x *types.Basic, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeChan

func (t FnTypeVisitor[I, X]) VisitTypeChan(i I, d Dir, o types.Object, x *types.Chan, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeFunc

func (t FnTypeVisitor[I, X]) VisitTypeFunc(i I, d Dir, o types.Object, x *types.Func, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeInterface

func (t FnTypeVisitor[I, X]) VisitTypeInterface(i I, d Dir, o types.Object, x *types.Interface, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeMap

func (t FnTypeVisitor[I, X]) VisitTypeMap(i I, d Dir, o types.Object, x *types.Map, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeName

func (t FnTypeVisitor[I, X]) VisitTypeName(i I, d Dir, name string, e *types.TypeName, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeNamed

func (t FnTypeVisitor[I, X]) VisitTypeNamed(i I, d Dir, o types.Object, x *types.Named, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeParam

func (t FnTypeVisitor[I, X]) VisitTypeParam(i I, d Dir, o types.Object, x *types.TypeParam, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypePointer

func (t FnTypeVisitor[I, X]) VisitTypePointer(i I, d Dir, o types.Object, x *types.Pointer, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeSignature

func (t FnTypeVisitor[I, X]) VisitTypeSignature(i I, d Dir, o types.Object, x *types.Signature, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeSlice

func (t FnTypeVisitor[I, X]) VisitTypeSlice(i I, d Dir, o types.Object, x *types.Slice, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeStruct

func (t FnTypeVisitor[I, X]) VisitTypeStruct(i I, d Dir, o types.Object, x *types.Struct, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeTuple

func (t FnTypeVisitor[I, X]) VisitTypeTuple(i I, d Dir, o types.Object, x *types.Tuple, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeUnion

func (t FnTypeVisitor[I, X]) VisitTypeUnion(i I, d Dir, o types.Object, x *types.Union, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitTypeVar

func (t FnTypeVisitor[I, X]) VisitTypeVar(i I, d Dir, o types.Object, x *types.Var, seen Types, cx X) bool

func (FnTypeVisitor[I, X]) VisitVar

func (t FnTypeVisitor[I, X]) VisitVar(i I, d Dir, name string, e *types.Var, cx X) bool

type Inspector

type Inspector interface {
	// contains filtered or unexported methods
}

type NodeDeclVisit

type NodeDeclVisit[I Inspector, T ast.Node, X any] func(i I, d Dir, name string, o *ast.Object, x T, seen Nodes, cx X) bool

type NodeExprVisit

type NodeExprVisit[I Inspector, T ast.Expr, X any] func(i I, d Dir, o *ast.Object, x T, seen Nodes, cx X) bool

type NodeVisit

type NodeVisit[I Inspector, T ast.Node, X any] func(i I, d Dir, o *ast.Object, x T, seen Nodes, cx X) bool

type NodeVisitor

type NodeVisitor[I Inspector, X any] interface {
	VisitFieldDecl(i I, d Dir, name string, o *ast.Object, x *ast.Field, seen Nodes, cx X) bool
	VisitFuncDecl(i I, d Dir, name string, o *ast.Object, x *ast.FuncDecl, nodes Nodes, cx X) bool
	VisitTypeDecl(i I, d Dir, name string, o *ast.Object, x *ast.TypeSpec, nodes Nodes, cx X) bool
	VisitValueDecl(i I, d Dir, name string, o *ast.Object, x *ast.ValueSpec, nodes Nodes, cx X) bool

	VisitFieldList(i I, d Dir, o *ast.Object, x *ast.FieldList, nodes Nodes, cx X) bool
	VisitField(i I, d Dir, o *ast.Object, x *ast.Field, seen Nodes, cx X) bool

	VisitIdent(i I, d Dir, o *ast.Object, x *ast.Ident, nodes Nodes, cx X) bool
	VisitFuncType(i I, d Dir, o *ast.Object, x *ast.FuncType, nodes Nodes, cx X) bool
	VisitStructType(i I, d Dir, o *ast.Object, x *ast.StructType, nodes Nodes, cx X) bool
	VisitInterfaceType(i I, d Dir, o *ast.Object, x *ast.InterfaceType, nodes Nodes, cx X) bool
	VisitArrayType(i I, d Dir, o *ast.Object, x *ast.ArrayType, nodes Nodes, cx X) bool
	VisitMapType(i I, d Dir, o *ast.Object, x *ast.MapType, nodes Nodes, cx X) bool
	VisitChanType(i I, d Dir, o *ast.Object, x *ast.ChanType, nodes Nodes, cx X) bool
	VisitStarExpr(i I, d Dir, o *ast.Object, x *ast.StarExpr, nodes Nodes, cx X) bool
	VisitSelectorExpr(i I, d Dir, o *ast.Object, x *ast.SelectorExpr, nodes Nodes, cx X) bool
	VisitBasicLit(i I, d Dir, o *ast.Object, x *ast.BasicLit, nodes Nodes, cx X) bool
	VisitEllipsis(i I, d Dir, o *ast.Object, x *ast.Ellipsis, nodes Nodes, cx X) bool
	VisitUnaryExpr(i I, d Dir, o *ast.Object, x *ast.UnaryExpr, nodes Nodes, cx X) bool
	VisitBinaryExpr(i I, d Dir, o *ast.Object, x *ast.BinaryExpr, nodes Nodes, cx X) bool
}

type Nodes

type Nodes = Stack[ast.Node]

type Stack

type Stack[T comparable] []T

func (Stack[T]) Clean

func (s Stack[T]) Clean() (x Stack[T])

func (*Stack[T]) CleanSitu

func (s *Stack[T]) CleanSitu()

func (Stack[T]) Empty

func (s Stack[T]) Empty() bool

func (Stack[T]) EndWith

func (s Stack[T]) EndWith(x ...T) bool

func (Stack[T]) Equals

func (s Stack[T]) Equals(x ...T) bool

func (Stack[T]) First

func (s Stack[T]) First() (v T)

func (Stack[T]) LNth

func (s Stack[T]) LNth(n int) T

func (Stack[T]) Last

func (s Stack[T]) Last() (v T)

func (Stack[T]) LastIndex

func (s Stack[T]) LastIndex(v T) int

func (Stack[T]) Len

func (s Stack[T]) Len() int

func (Stack[T]) MaxIdx

func (s Stack[T]) MaxIdx() int

func (Stack[T]) NotEmpty

func (s Stack[T]) NotEmpty() bool

func (Stack[T]) Nth

func (s Stack[T]) Nth(n int) T

func (Stack[T]) Pop

func (s Stack[T]) Pop() (x Stack[T], v T)

func (*Stack[T]) PopSitu

func (s *Stack[T]) PopSitu() (v T)

func (Stack[T]) Push

func (s Stack[T]) Push(v T) (x Stack[T])

func (*Stack[T]) PushSitu

func (s *Stack[T]) PushSitu(v T)

func (Stack[T]) StartWith

func (s Stack[T]) StartWith(x ...T) bool

type TypeElementTypeVisitor

type TypeElementTypeVisitor[I Inspector, T types.Type, X any] func(i I, d Dir, o types.Object, x T, seen Types, cx X) bool

type TypeElementVisitor

type TypeElementVisitor[I Inspector, T types.Object, X any] func(i I, d Dir, o types.Object, x T, seen Types, cx X) bool

type TypeInspector

type TypeInspector[X any] struct {
	WithUnexported bool
	Visitor        TypeVisitor[*TypeInspector[X], X]
	Pkg            *packages.Package
	Face           map[Face]struct{}
	X              X
	PopEach        bool //pop each Type when done
	TypePath            //the path from root to leaf, which is cutoff branches when current node is [ KMField ], [ KMParam ], [ KMResult ]; not include current visit node
}

func (*TypeInspector[X]) Implements

func (s *TypeInspector[X]) Implements(p types.Type) (m []Face)

func (*TypeInspector[X]) LoadFaces

func (s *TypeInspector[X]) LoadFaces()

func (*TypeInspector[X]) OnEnter

func (s *TypeInspector[X]) OnEnter(kind TypeKind)

func (*TypeInspector[X]) OnExit

func (s *TypeInspector[X]) OnExit(kind TypeKind)

type TypeKind

type TypeKind int
const (
	KNone TypeKind = iota
	KTFunc
	KTType
	KTConst
	KTVar

	KVar
	KFunc

	KNamed
	KStruct
	KMap
	KPointer
	KArray
	KSlice
	KInterface
	KChan
	KBasic
	KTypeParam
	KSignature
	KUnion
	KTuple
	KTerm

	// KMField current branch are fields
	KMField

	KMMapKey
	KMMapValue
	KMMethod
	// KMParam current branch are parameters
	KMParam

	// KMResult current branch are results
	KMResult
	// KMEmbedded current branch are interface embedded
	KMEmbedded
)

func (TypeKind) String

func (i TypeKind) String() string

type TypePath

type TypePath = Stack[TypeKind]

type TypeRootVisitor

type TypeRootVisitor[I Inspector, T types.Object, X any] func(i I, d Dir, name string, e T, cx X) bool

type TypeVisitor

type TypeVisitor[I Inspector, X any] interface {
	VisitConst(i I, d Dir, name string, e *types.Const, cx X) bool
	VisitFunc(i I, d Dir, name string, e *types.Func, cx X) bool
	VisitTypeName(i I, d Dir, name string, e *types.TypeName, cx X) bool
	VisitVar(i I, d Dir, name string, e *types.Var, cx X) bool

	VisitTypeVar(i I, d Dir, o types.Object, x *types.Var, seen Types, cx X) bool
	VisitTypeFunc(i I, d Dir, o types.Object, x *types.Func, seen Types, cx X) bool

	VisitTypeBasic(i I, d Dir, o types.Object, x *types.Basic, seen Types, cx X) bool
	VisitTypeMap(i I, d Dir, o types.Object, x *types.Map, seen Types, cx X) bool
	VisitTypeArray(i I, d Dir, o types.Object, x *types.Array, seen Types, cx X) bool
	VisitTypeStruct(i I, d Dir, o types.Object, x *types.Struct, seen Types, cx X) bool
	VisitTypeTuple(i I, d Dir, o types.Object, x *types.Tuple, seen Types, cx X) bool
	VisitTypeUnion(i I, d Dir, o types.Object, x *types.Union, seen Types, cx X) bool
	VisitTypeSignature(i I, d Dir, o types.Object, x *types.Signature, seen Types, cx X) bool
	VisitTypeParam(i I, d Dir, o types.Object, x *types.TypeParam, seen Types, cx X) bool
	VisitTypePointer(i I, d Dir, o types.Object, x *types.Pointer, seen Types, cx X) bool
	VisitTypeSlice(i I, d Dir, o types.Object, x *types.Slice, seen Types, cx X) bool
	VisitTypeInterface(i I, d Dir, o types.Object, x *types.Interface, seen Types, cx X) bool
	VisitTypeChan(i I, d Dir, o types.Object, x *types.Chan, seen Types, cx X) bool
	VisitTypeNamed(i I, d Dir, o types.Object, x *types.Named, seen Types, cx X) bool
}

type Types

type Types Stack[types.Type]

func (Types) IsEmpty

func (t Types) IsEmpty() bool

func (Types) LNth

func (t Types) LNth(n int) types.Type

func (Types) LNthArray

func (t Types) LNthArray(n int) (v *types.Array)

func (Types) LNthBasic

func (t Types) LNthBasic(n int) (v *types.Basic)

func (Types) LNthChan

func (t Types) LNthChan(n int) (v *types.Chan)

func (Types) LNthInterface

func (t Types) LNthInterface(n int) (v *types.Interface)

func (Types) LNthMap

func (t Types) LNthMap(n int) (v *types.Map)

func (Types) LNthNamed

func (t Types) LNthNamed(n int) (v *types.Named)

func (Types) LNthPointer

func (t Types) LNthPointer(n int) (v *types.Pointer)

func (Types) LNthSignature

func (t Types) LNthSignature(n int) (v *types.Signature)

func (Types) LNthSlice

func (t Types) LNthSlice(n int) (v *types.Slice)

func (Types) LNthStruct

func (t Types) LNthStruct(n int) (v *types.Struct)

func (Types) LNthTuple

func (t Types) LNthTuple(n int) (v *types.Tuple)

func (Types) LNthTypeParam

func (t Types) LNthTypeParam(n int) (v *types.TypeParam)

func (Types) LNthUnion

func (t Types) LNthUnion(n int) (v *types.Union)

func (Types) Nth

func (t Types) Nth(n int) types.Type

func (Types) NthArray

func (t Types) NthArray(n int) (v *types.Array)

func (Types) NthBasic

func (t Types) NthBasic(n int) (v *types.Basic)

func (Types) NthChan

func (t Types) NthChan(n int) (v *types.Chan)

func (Types) NthInterface

func (t Types) NthInterface(n int) (v *types.Interface)

func (Types) NthMap

func (t Types) NthMap(n int) (v *types.Map)

func (Types) NthNamed

func (t Types) NthNamed(n int) (v *types.Named)

func (Types) NthPointer

func (t Types) NthPointer(n int) (v *types.Pointer)

func (Types) NthSignature

func (t Types) NthSignature(n int) (v *types.Signature)

func (Types) NthSlice

func (t Types) NthSlice(n int) (v *types.Slice)

func (Types) NthStruct

func (t Types) NthStruct(n int) (v *types.Struct)

func (Types) NthTuple

func (t Types) NthTuple(n int) (v *types.Tuple)

func (Types) NthTypeParam

func (t Types) NthTypeParam(n int) (v *types.TypeParam)

func (Types) NthUnion

func (t Types) NthUnion(n int) (v *types.Union)

type Writer

type Writer interface {
	Buffer() *bytes.Buffer
	Reset()
	UnWrite(n int)
	Format(format string, args ...any) Writer
	Append(w Writer) Writer
	Free()
	NotEmpty() bool
	LF() Writer
	Indent(n int) Writer
	Bytes() []byte
	fmt.Stringer
}

func GetWriter

func GetWriter() Writer

Jump to

Keyboard shortcuts

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