extract

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgsFromFields

func ArgsFromFields(file *types.GoFile, fields *ast.FieldList) types.Args

ArgsFromFields extract types.Args from *ast.FieldList

func DepPackagePathFromModule

func DepPackagePathFromModule(moduleName, modulePath, pkg string) string

DepPackagePathFromModule returns fs path for pkg, given moduleName and modulePath

func DependenciesFromGoMod

func DependenciesFromGoMod(data string) ([]types.Dependency, error)

func DependencyForPackage

func DependencyForPackage(pkg string, deps []types.Dependency) *types.Dependency

DependencyForPackage return corresponding *types.Dependency for pkg

func GoFile added in v0.1.0

func GoFile(path string) (*types.GoFile, error)

GoFile exported func TODO: edit

func GoMod

func GoMod(path string) ([]byte, error)

func GoSourceFilesFromPackage

func GoSourceFilesFromPackage(pkgPath string) ([]string, error)

GoSourceFilesFromPackage returns list of *.go src files in pkgPath package except doc.go, *_test.go

func ImportStringForPackage added in v0.1.0

func ImportStringForPackage(file *types.GoFile, pkg string) string

func InterfaceFromTypeSpec

func InterfaceFromTypeSpec(file *types.GoFile, typeSpec *ast.TypeSpec) *types.Interface

InterfaceFromTypeSpec extract interface from *ast.TypeSpec

func InterfacesFromASTFile

func InterfacesFromASTFile(file *types.GoFile) []types.Interface

InterfacesFromASTFile extract from *ast.File

func ModuleNameFromGoMod

func ModuleNameFromGoMod(path string) (string, error)

ModuleNameFromGoMod read go.mod from path, returns module name or error

func ParseFile added in v0.1.0

func ParseFile(ctx *Context, path string, query string, depth int) ([]*types.Interface, []*types.Struct, error)

ParseFile exported func TODO: edit

func Path4Package added in v0.1.0

func Path4Package(moduleName, modulePath, pkgImportPath, fileOrPackage string) (string, error)

Path4Package returns pkg source dir path;

func SearchFile added in v0.1.0

func SearchFile(file string) (string, error)

SearchFile looks for file in current directory

func SearchFileUp

func SearchFileUp(file, dir string, heightLimit int) (string, error)

SearchFileUp looks for file in heightLimit directories up

func SearchGoModUp

func SearchGoModUp(dir string, heightLimit int) (string, error)

SearchGoModUp is SearchFileUp for go.mod

func StructFromTypeSpec

func StructFromTypeSpec(file *types.GoFile, typeSpec *ast.TypeSpec) *types.Struct

StructFromTypeSpec extract *types.Struct from *ast.TypeSpec

func TypeDefs added in v0.1.0

func TypeDefs(ctx *Context, file *types.GoFile, name string, depth int) ([]*types.Interface, []*types.Struct, error)

TypeDefs exported func TODO: edit

func TypeFromArrayType

func TypeFromArrayType(file *types.GoFile, at *ast.ArrayType) types.Type

func TypeFromEllipsis

func TypeFromEllipsis(file *types.GoFile, el *ast.Ellipsis) types.Type

func TypeFromExpr

func TypeFromExpr(file *types.GoFile, field ast.Expr) types.Type

func TypeFromIdent

func TypeFromIdent(file *types.GoFile, id *ast.Ident) types.Type

func TypeFromMapType

func TypeFromMapType(file *types.GoFile, mt *ast.MapType) types.Type

func TypeFromPackage added in v0.1.0

func TypeFromPackage(ctx *Context, file *types.GoFile, pkgName string, name string, depth int) ([]*types.Interface, []*types.Struct, error)

TypeFromPackage 1. get package import path. 2. Get source files in this package. 3. Look for name definition in package files

func TypeFromSelectorExpr

func TypeFromSelectorExpr(file *types.GoFile, se *ast.SelectorExpr) types.Type

func TypeFromStarExpr

func TypeFromStarExpr(file *types.GoFile, se *ast.StarExpr) types.Type

func TypeIndex added in v0.1.0

func TypeIndex(pkgImportStr, typeName string) string

func TypesFromASTFile

func TypesFromASTFile(file *types.GoFile) ([]*types.Interface, []*types.Struct)

TypesFromASTFile exported func TODO: edit

func TypesRecursive added in v0.1.0

func TypesRecursive(ctx *Context, file *types.GoFile, ifaces []*types.Interface, structs []*types.Struct, depth int) ([]*types.Interface, []*types.Struct, error)

TypesRecursive looks for non-builtin types in ifaces & structs. Try to find in sources. Return found.

Types

type Context added in v0.1.0

type Context struct {
	Interface map[string]*types.Interface
	Struct    map[string]*types.Struct
	File      map[string]*types.GoFile
	Type      map[string]types.Type
}

func NewContext added in v0.1.0

func NewContext() *Context

func (Context) GetInterface added in v0.1.0

func (c Context) GetInterface(t types.Type) *types.Interface

func (Context) GetStruct added in v0.1.0

func (c Context) GetStruct(t types.Type) *types.Struct

func (Context) String added in v0.1.0

func (c Context) String() string

type Interfaces

type Interfaces interface {
	Extract() []types.Interface
}

Jump to

Keyboard shortcuts

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