Documentation ¶
Index ¶
- Variables
- func ExprToString(expr ast.Expr) string
- func GetTypeStars(t Type) int
- func InspectUnderlyingStruct(t Type, inspect func(*Field) bool) bool
- func IsAtomicType(t Type) bool
- func IsErrorType(t Type) bool
- func NotNilPointerValue(t *PointerType, file *File) ast.Expr
- func ParseExpr(x string) (ast.Expr, error)
- func ResolveUnknownField(field *Field)
- func TypeAssignable(target, source Type) bool
- func TypeEqual(a, b Type) bool
- func TypeEqualAsReceiver(t1 Type, t2 Type) bool
- func TypeExprInFile(t Type, file *File) ast.Expr
- func TypeInitValue(t Type, file *File) ast.Expr
- func TypeIsUnknown(t Type) bool
- func TypeZeroValue(t Type, file *File) ast.Expr
- func WalkFile(file *File, walker DeclWalker)
- func WalkPackage(pkg *Package, walker DeclWalker)
- type ArrayType
- func (t *ArrayType) AssignableTo(tt Type) bool
- func (t *ArrayType) Copy() Type
- func (t *ArrayType) DefaultValue() ast.Expr
- func (t *ArrayType) EqualTo(tt Type) bool
- func (t *ArrayType) File() *File
- func (t *ArrayType) LenExpr() ast.Expr
- func (t *ArrayType) Name() string
- func (t *ArrayType) Package() *Package
- func (t *ArrayType) String() string
- func (t *ArrayType) Underlying() Type
- type BasicType
- func (t *BasicType) AssignableTo(Type) bool
- func (t *BasicType) Copy() Type
- func (t *BasicType) DefaultValue() ast.Expr
- func (t *BasicType) EqualTo(tt Type) bool
- func (t *BasicType) File() *File
- func (t *BasicType) Name() string
- func (t *BasicType) Package() *Package
- func (t *BasicType) String() string
- func (t *BasicType) Underlying() Type
- type DeclFinder
- type DeclNode
- type DeclWalker
- type Direction
- type Field
- type File
- func (file *File) AddImport(name string, pkg *Package)
- func (file *File) DotImported() []*Package
- func (f *File) FindAllDotImport() (paths []string)
- func (file *File) FindDecl(expr ast.Expr, finder DeclFinder) *DeclNode
- func (file *File) FindImport(name string) *Package
- func (file *File) FindImportNameByPath(path string) string
- func (f *File) FindImportPath(name string) (path string, ok bool)
- func (f *File) ImportAllDots() []*Package
- func (file *File) LookupImport(name string) (*File, *ast.Object)
- func (file *File) LookupMethod(name string) ([]*File, []*ast.FuncDecl)
- func (file *File) LookupName(name string) (*File, *ast.Object)
- func (file *File) ReduceType(expr ast.Expr) Type
- func (file *File) ReduceTypeSrc(src string) Type
- type FuncDeclFinder
- type FuncDeclWalker
- type FuncType
- func (t *FuncType) AssignableTo(Type) bool
- func (t *FuncType) Copy() Type
- func (t *FuncType) DefaultValue() ast.Expr
- func (t *FuncType) EqualTo(Type) bool
- func (t *FuncType) File() *File
- func (*FuncType) Name() string
- func (t *FuncType) Package() *Package
- func (t *FuncType) String() string
- func (t *FuncType) Underlying() Type
- type GenDeclFinder
- type GenDeclWalker
- type InterfaceType
- func (t *InterfaceType) AssignableTo(tt Type) bool
- func (t *InterfaceType) Copy() Type
- func (t *InterfaceType) DefaultValue() ast.Expr
- func (t *InterfaceType) EqualTo(tt Type) bool
- func (t *InterfaceType) File() *File
- func (t *InterfaceType) GetFuncByName(name string) Type
- func (t *InterfaceType) Name() string
- func (t *InterfaceType) Package() *Package
- func (t *InterfaceType) String() string
- func (t *InterfaceType) Underlying() Type
- type InterfaceTypeFinder
- type OldFuncType
- type OldInterface
- type Package
- func (pkg *Package) EqualTo(np *Package) bool
- func (pkg *Package) FindDecl(name string, finder DeclFinder) *DeclNode
- func (pkg *Package) FindFuncDecl(name string) *DeclNode
- func (pkg *Package) GetFile(name string) *File
- func (pkg *Package) InsertFile(file *File, index int)
- func (pkg *Package) ReduceType(expr ast.Expr) (*File, Type)
- type Parser
- func (p *Parser) AddScope(canonicalPath string, scope *Scope)
- func (p *Parser) ImportPackage(name string, path string, srcDir string) *Package
- func (p *Parser) ImportScope(path string, dir string) (canonicalPath string, scope *Scope)
- func (p *Parser) InsertFileToPackage(pkg *Package, file *File, index int)
- func (p *Parser) ParseFileContent(name string, content interface{}) *File
- func (p *Parser) ParsePackage(path string, directory string, names []string) *Package
- func (p *Parser) ParsePackageDir(directory string) *Package
- func (p *Parser) ParsePackageFiles(names []string) *Package
- func (p *Parser) PrintNode(node ast.Node)
- type PointerType
- func (t *PointerType) AssignableTo(tt Type) bool
- func (t *PointerType) BaseType() Type
- func (t *PointerType) Copy() Type
- func (t *PointerType) DefaultValue() ast.Expr
- func (t *PointerType) EqualTo(tt Type) bool
- func (t *PointerType) File() *File
- func (t *PointerType) Name() string
- func (t *PointerType) Package() *Package
- func (t *PointerType) String() string
- func (t *PointerType) Underlying() Type
- type Scope
- type StructType
- func (t *StructType) AssignableTo(tt Type) bool
- func (t *StructType) Copy() Type
- func (t *StructType) DefaultValue() ast.Expr
- func (t *StructType) EqualTo(tt Type) bool
- func (t *StructType) File() *File
- func (t *StructType) Name() string
- func (t *StructType) Package() *Package
- func (t *StructType) String() string
- func (t *StructType) Underlying() Type
- type StructTypeFinder
- type TPath
- func (tp *TPath) ConflictWith(ot *TPath) bool
- func (tp *TPath) Copy() *TPath
- func (tp *TPath) String() string
- func (tp *TPath) WithArg(arg interface{}) *TPath
- func (tp *TPath) WithDirection(d Direction) *TPath
- func (tp *TPath) WithFunction(funcType Type) *TPath
- func (tp *TPath) WithTypeConversion(t Type) *TPath
- type Type
- func ErrorType() Type
- func GetInterfaceFuncByName(t Type, name string) Type
- func MapType(key Type, val Type) Type
- func NewBasicType(name string) Type
- func NewType(name string) Type
- func ParseType(node ast.Node) Type
- func ParseTypeString(str string) Type
- func TypeSkipBracket(t Type, n int) Type
- func TypeSkipPointer(t Type, n int) Type
- func TypeWithArray(t Type, len int) Type
- func TypeWithExpr(t Type, expr ast.Expr) Type
- func TypeWithFile(t Type, file *File) Type
- func TypeWithName(underlying Type, name string) Type
- func TypeWithPointer(t Type) Type
- func TypeWithSlice(t Type) Type
- func TypeWrapStruct(t Type, name string) Type
- type TypeSpecFinder
- type UnknownType
- func (t *UnknownType) AssignableTo(Type) bool
- func (t *UnknownType) Copy() Type
- func (t *UnknownType) DefaultValue() ast.Expr
- func (t *UnknownType) EqualTo(Type) bool
- func (t *UnknownType) File() *File
- func (t *UnknownType) Name() string
- func (t *UnknownType) Package() *Package
- func (unknown *UnknownType) Reduce(file *File) Type
- func (unknown *UnknownType) ResetParent(kn Type)
- func (t *UnknownType) String() string
- func (t *UnknownType) Underlying() Type
- func (t *UnknownType) WithFile(f *File) *UnknownType
- type ValueSpecFinder
Constants ¶
This section is empty.
Variables ¶
View Source
var Universe = NewScope()
View Source
var UniverseScope = ast.NewScope(nil)
Functions ¶
func ExprToString ¶
func GetTypeStars ¶
func IsAtomicType ¶
func IsErrorType ¶
func NotNilPointerValue ¶
func NotNilPointerValue(t *PointerType, file *File) ast.Expr
func ResolveUnknownField ¶
func ResolveUnknownField(field *Field)
func TypeAssignable ¶
func TypeEqualAsReceiver ¶
func TypeIsUnknown ¶
func WalkFile ¶
func WalkFile(file *File, walker DeclWalker)
func WalkPackage ¶
func WalkPackage(pkg *Package, walker DeclWalker)
Types ¶
type ArrayType ¶
func (*ArrayType) AssignableTo ¶
func (*ArrayType) DefaultValue ¶
func (*ArrayType) Underlying ¶
type BasicType ¶
type BasicType struct {
// contains filtered or unexported fields
}
Define: basicType: for golang pre defeined type
func (*BasicType) AssignableTo ¶
func (*BasicType) DefaultValue ¶
func (*BasicType) Underlying ¶
type DeclFinder ¶
type DeclFinder interface { Find(ast.Decl) *DeclNode WithName(name string) DeclFinder }
func NewFuncDeclFinder ¶
func NewFuncDeclFinder(recvName string) DeclFinder
func NewGenDeclFinder ¶
func NewGenDeclFinder(tok token.Token) DeclFinder
func NewInterfaceTypeFinder ¶
func NewInterfaceTypeFinder() DeclFinder
func NewStructTypeFinder ¶
func NewStructTypeFinder() DeclFinder
func NewTypeSpecFinder ¶
func NewTypeSpecFinder() DeclFinder
func NewValueSpecFinder ¶
func NewValueSpecFinder() DeclFinder
type DeclWalker ¶
func NewFuncDeclWalker ¶
func NewFuncDeclWalker(walk func(*ast.FuncDecl) bool) DeclWalker
func NewGenDeclWalker ¶
type Direction ¶
type Direction int
const ( D_Self Direction D_SkipPointer D_SkipBracket D_SpreadFields D_CallFunction //call function D_AddPointer D_AddBracket D_TypeConversion )
type File ¶
type File struct { BelongTo *Package Name string File *ast.File // contains filtered or unexported fields }
func (*File) DotImported ¶
func (*File) FindAllDotImport ¶
func (*File) FindDecl ¶
func (file *File) FindDecl(expr ast.Expr, finder DeclFinder) *DeclNode
GenDecl FuncDecl
func (*File) FindImport ¶
func (*File) FindImportNameByPath ¶
func (*File) ImportAllDots ¶
func (*File) LookupMethod ¶
method need lookup
func (*File) ReduceTypeSrc ¶
type FuncDeclFinder ¶
func (*FuncDeclFinder) WithName ¶
func (finder *FuncDeclFinder) WithName(name string) DeclFinder
type FuncDeclWalker ¶
type FuncDeclWalker struct {
// contains filtered or unexported fields
}
type FuncType ¶
Define: FuncType
func (*FuncType) AssignableTo ¶
func (*FuncType) DefaultValue ¶
func (*FuncType) Underlying ¶
type GenDeclFinder ¶
func (*GenDeclFinder) WithName ¶
func (finder *GenDeclFinder) WithName(name string) DeclFinder
type GenDeclWalker ¶
type InterfaceType ¶
type InterfaceType struct {
Methods []*Field
}
Define: InterfaceType
func (*InterfaceType) AssignableTo ¶
func (t *InterfaceType) AssignableTo(tt Type) bool
func (*InterfaceType) Copy ¶
func (t *InterfaceType) Copy() Type
func (*InterfaceType) DefaultValue ¶
func (t *InterfaceType) DefaultValue() ast.Expr
func (*InterfaceType) EqualTo ¶
func (t *InterfaceType) EqualTo(tt Type) bool
func (*InterfaceType) File ¶
func (t *InterfaceType) File() *File
func (*InterfaceType) GetFuncByName ¶
func (t *InterfaceType) GetFuncByName(name string) Type
func (*InterfaceType) Name ¶
func (t *InterfaceType) Name() string
func (*InterfaceType) Package ¶
func (t *InterfaceType) Package() *Package
func (*InterfaceType) String ¶
func (t *InterfaceType) String() string
func (*InterfaceType) Underlying ¶
func (t *InterfaceType) Underlying() Type
type InterfaceTypeFinder ¶
type InterfaceTypeFinder struct {
// contains filtered or unexported fields
}
func (*InterfaceTypeFinder) WithName ¶
func (finder *InterfaceTypeFinder) WithName(name string) DeclFinder
type OldFuncType ¶
type OldFuncType struct { Expr ast.Expr Package *Package Name *ast.Ident OldFuncType *ast.FuncType Signature string }
func NewOldFuncType ¶
func NewOldFuncType(name string) *OldFuncType
func (*OldFuncType) CopyAstOldFuncType ¶
func (ft *OldFuncType) CopyAstOldFuncType() *ast.FuncType
func (*OldFuncType) CopyAstOldFuncTypeToPackage ¶
func (ft *OldFuncType) CopyAstOldFuncTypeToPackage(pkg *Package) *ast.FuncType
func (*OldFuncType) Fill ¶
func (ft *OldFuncType) Fill(node *DeclNode)
type OldInterface ¶
type OldInterface struct {
OldFuncTypes []*OldFuncType
}
func NewOldInterface ¶
func NewOldInterface() *OldInterface
func (*OldInterface) Fill ¶
func (i *OldInterface) Fill(node *DeclNode)
func (*OldInterface) GetFuncByName ¶
func (i *OldInterface) GetFuncByName(name string) *OldFuncType
type Package ¶
type Package struct { Scope *Scope Name string Dir string Path string CanonicalPath string PackageName string Files []*File // contains filtered or unexported fields }
func NewPackage ¶
func (*Package) FindDecl ¶
func (pkg *Package) FindDecl(name string, finder DeclFinder) *DeclNode
FindDecl
func (*Package) InsertFile ¶
type Parser ¶
type Parser struct { FileSet *token.FileSet Scope *ast.Scope ImportContext build.Context Scopes map[string]*Scope }
func (*Parser) ImportPackage ¶
func (*Parser) ImportScope ¶
func (*Parser) InsertFileToPackage ¶
func (*Parser) ParseFileContent ¶
func (*Parser) ParsePackage ¶
parsePackage analyzes the single package constructed from the named files.
func (*Parser) ParsePackageDir ¶
func (*Parser) ParsePackageFiles ¶
parsePackageFiles parses the package occupying the named files.
type PointerType ¶
Define: PointerType
func (*PointerType) AssignableTo ¶
func (t *PointerType) AssignableTo(tt Type) bool
func (*PointerType) BaseType ¶
func (t *PointerType) BaseType() Type
func (*PointerType) Copy ¶
func (t *PointerType) Copy() Type
func (*PointerType) DefaultValue ¶
func (t *PointerType) DefaultValue() ast.Expr
func (*PointerType) EqualTo ¶
func (t *PointerType) EqualTo(tt Type) bool
func (*PointerType) File ¶
func (t *PointerType) File() *File
func (*PointerType) Name ¶
func (t *PointerType) Name() string
func (*PointerType) Package ¶
func (t *PointerType) Package() *Package
func (*PointerType) String ¶
func (t *PointerType) String() string
func (*PointerType) Underlying ¶
func (t *PointerType) Underlying() Type
type StructType ¶
type StructType struct {
Fields []*Field
}
Define: StructType
func (*StructType) AssignableTo ¶
func (t *StructType) AssignableTo(tt Type) bool
func (*StructType) Copy ¶
func (t *StructType) Copy() Type
func (*StructType) DefaultValue ¶
func (t *StructType) DefaultValue() ast.Expr
func (*StructType) EqualTo ¶
func (t *StructType) EqualTo(tt Type) bool
func (*StructType) File ¶
func (t *StructType) File() *File
func (*StructType) Name ¶
func (t *StructType) Name() string
func (t *StructType) PackageName() string { return "" }
func (*StructType) Package ¶
func (t *StructType) Package() *Package
func (*StructType) String ¶
func (t *StructType) String() string
func (*StructType) Underlying ¶
func (t *StructType) Underlying() Type
type StructTypeFinder ¶
type StructTypeFinder struct {
// contains filtered or unexported fields
}
func (*StructTypeFinder) WithName ¶
func (finder *StructTypeFinder) WithName(name string) DeclFinder
type TPath ¶
type TPath struct { Source Type Target Type D Direction Arg interface{} // contains filtered or unexported fields }
func (*TPath) ConflictWith ¶
func (*TPath) WithDirection ¶
func (*TPath) WithFunction ¶
func (*TPath) WithTypeConversion ¶
type Type ¶
type Type interface { Copy() Type File() *File Package() *Package Name() string AssignableTo(Type) bool EqualTo(Type) bool Underlying() Type String() string }
func GetInterfaceFuncByName ¶
func NewBasicType ¶
func ParseTypeString ¶
func TypeSkipBracket ¶
func TypeSkipPointer ¶
func TypeWithArray ¶
func TypeWithFile ¶
func TypeWithName ¶
func TypeWithPointer ¶
func TypeWithSlice ¶
func TypeWrapStruct ¶
type TypeSpecFinder ¶
type TypeSpecFinder struct { Name string // contains filtered or unexported fields }
func (*TypeSpecFinder) WithName ¶
func (finder *TypeSpecFinder) WithName(name string) DeclFinder
type UnknownType ¶
type UnknownType struct { Parent Type // contains filtered or unexported fields }
Define wrapper: UnknownType
func NewUnknownType ¶
func NewUnknownType(file *File, expr ast.Expr) *UnknownType
func TypeHasUnknown ¶
func TypeHasUnknown(t Type) (*UnknownType, bool)
func (*UnknownType) AssignableTo ¶
func (t *UnknownType) AssignableTo(Type) bool
func (*UnknownType) Copy ¶
func (t *UnknownType) Copy() Type
func (*UnknownType) DefaultValue ¶
func (t *UnknownType) DefaultValue() ast.Expr
func (*UnknownType) EqualTo ¶
func (t *UnknownType) EqualTo(Type) bool
func (*UnknownType) File ¶
func (t *UnknownType) File() *File
func (*UnknownType) Name ¶
func (t *UnknownType) Name() string
func (*UnknownType) Package ¶
func (t *UnknownType) Package() *Package
func (*UnknownType) Reduce ¶
func (unknown *UnknownType) Reduce(file *File) Type
func (*UnknownType) ResetParent ¶
func (unknown *UnknownType) ResetParent(kn Type)
func (*UnknownType) String ¶
func (t *UnknownType) String() string
func (*UnknownType) Underlying ¶
func (t *UnknownType) Underlying() Type
func (*UnknownType) WithFile ¶
func (t *UnknownType) WithFile(f *File) *UnknownType
type ValueSpecFinder ¶
type ValueSpecFinder struct { Name string // contains filtered or unexported fields }
func (*ValueSpecFinder) WithName ¶
func (finder *ValueSpecFinder) WithName(name string) DeclFinder
Click to show internal directories.
Click to hide internal directories.