search

package
v0.0.0-...-ac4698a Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportedFilter

func ExportedFilter(tgt Target) bool

ExportedFilter selects an exported target.

func UniverseFilter

func UniverseFilter(tgt Target) bool

UniverseFilter selects a builtin target.

Types

type Def

type Def interface {
	ValueSpecs() []*ast.ValueSpec // var, const, field
	FuncDecls() []*ast.FuncDecl   // func, method
	TypeSpecs() []*ast.TypeSpec   // type alias, defined type
	// Iterate visits all specs and decls until given function returns false.
	Iterate(func(ast.Node) bool)
}

Def is a set of the top level definitions of a package.

func NewDef

func NewDef(valueSpecs []*ast.ValueSpec, funcDecls []*ast.FuncDecl, typeSpecs []*ast.TypeSpec) Def

type DefExtractor

type DefExtractor interface {
	Extract(f *ast.File) Def
}

func NewDefExtractor

func NewDefExtractor() DefExtractor

type DefNode

type DefNode interface {
	Node
}

func NewDefNode

func NewDefNode(pkg Pkg, obj Object, info *NodeInfo) DefNode

type DefSet

type DefSet interface {
	Pkg() *packages.Package
	Defs() []Def
}

func NewDefSet

func NewDefSet(pkg *packages.Package, defs []Def) DefSet

type DefSetExtractor

type DefSetExtractor interface {
	Extract(pkg *packages.Package) DefSet
}

func NewDefSetExtractor

func NewDefSetExtractor(extractor DefExtractor) DefSetExtractor

type FieldSearcher

type FieldSearcher interface {
	Search(pkg *types.Package, pos token.Pos) (*types.TypeName, bool)
}

func NewFieldSearcher

func NewFieldSearcher(pkgs []*types.Package) FieldSearcher

func NewFieldSearcherFromPackages

func NewFieldSearcherFromPackages(pkgs []*packages.Package) FieldSearcher

type FieldSearcherBuilder

type FieldSearcherBuilder interface {
	Add(*types.Package)
	Build() FieldSearcher
}

func NewFieldSearcherBuilder

func NewFieldSearcherBuilder() FieldSearcherBuilder

type Filter

type Filter func(Target) bool

Filter selects a target.

func DefSetFilter

func DefSetFilter(setList []DefSet) Filter

DefSetFilter selects a target belongs to the defs.

func ObjectNameFilter

func ObjectNameFilter(pair util.RegexpPair) Filter

ObjectNameFilter selects a target whose object name matched.

func OtherPkgFilter

func OtherPkgFilter(pkgs []*packages.Package) Filter

OtherPkgFilter selects a target whose package name is not matched with given packages.

func PkgNameFilter

func PkgNameFilter(pair util.RegexpPair) Filter

PkgNameFilter selects a target whose package name matched.

func (Filter) And

func (s Filter) And(next Filter) Filter

func (Filter) Or

func (s Filter) Or(next Filter) Filter

type Node

type Node interface {
	Pkg() Pkg
	Obj() Object
	Type() NodeType
	Name() string
	RecvString(opt ...NodeOption) string
	Info() *NodeInfo
}

type NodeConfig

type NodeConfig struct {
	// contains filtered or unexported fields
}

type NodeInfo

type NodeInfo struct {
	// ValueSpecIndex is the index of the ValueSpec.Specs that correspond to Obj() if AST() is ValueSpec.
	// -1 is a invalid value.
	ValueSpecIndex int
	Recv           string
}

type NodeOption

type NodeOption func(*NodeConfig)

func WithNodeRawRecv

func WithNodeRawRecv(v bool) NodeOption

type NodeType

type NodeType int
const (
	UnknownNodeType NodeType = iota
	BuiltinNodeType
	FuncNodeType
	MethodNodeType
	TypeNodeType
	VarNodeType
	ConstNodeType
	FieldNodeType
)

func NewNodeType

func NewNodeType(obj Object) NodeType

func (NodeType) String

func (s NodeType) String() string

type ObjExtractor

type ObjExtractor interface {
	// Extract extracts an object with the ident.
	Extract(pkg *packages.Package, ident *ast.Ident) (Object, bool)
}

func NewObjExtractor

func NewObjExtractor() ObjExtractor

type Object

type Object interface {
	Parent() *types.Scope
	Pos() token.Pos
	Pkg() *types.Package
	Name() string
	Type() types.Type
	Exported() bool
	Id() string
}

Object is the set of the public methods of types.Object.

type Pkg

type Pkg interface {
	Pkg() *packages.Package
	Name() string
	Path() string
	IsBuiltin() bool
}

func NewBuiltinPkg

func NewBuiltinPkg() Pkg

func NewPkg

func NewPkg(pkg *packages.Package) Pkg

func NewPkgWithName

func NewPkgWithName(name, path string) Pkg

type RefNode

type RefNode interface {
	Node
	AST() ast.Node
	Ident() *ast.Ident
}

func NewRefNode

func NewRefNode(pkg Pkg, obj Object, info *NodeInfo, astNode ast.Node, ident *ast.Ident) RefNode

type RefPkgSearcher

type RefPkgSearcher interface {
	Search(pkg *packages.Package, pos token.Pos) (ast.Node, bool)
}

func NewRefPkgSearcher

func NewRefPkgSearcher(searcher RefSearcher, defSets []DefSet) RefPkgSearcher

type RefSearcher

type RefSearcher interface {
	// Search returns a node if the pos is contained in the node.
	Search(defSet DefSet, pos token.Pos) (node ast.Node, found bool)
}

func NewRefSearcher

func NewRefSearcher() RefSearcher

type Target

type Target interface {
	Ident() *ast.Ident // ref
	Obj() Object       // def
}

Target is the dependency of the object.

func NewTarget

func NewTarget(ident *ast.Ident, obj Object) Target

type TargetExtractor

type TargetExtractor interface {
	Extract(pkg *packages.Package, filter Filter) <-chan Target
}

func NewTargetExtractor

func NewTargetExtractor(opt ...TargetExtractorOption) TargetExtractor

type TargetExtractorConfig

type TargetExtractorConfig struct {
	// contains filtered or unexported fields
}

type TargetExtractorOption

type TargetExtractorOption func(*TargetExtractorConfig)

func WithTargetExtractorResultBufferSize

func WithTargetExtractorResultBufferSize(v int) TargetExtractorOption

type Use

type Use interface {
	Ref() RefNode
	Def() DefNode
}

func NewUse

func NewUse(ref RefNode, def DefNode) Use

type UseSearcher

type UseSearcher interface {
	Search() <-chan Use
}

func NewUseSearcher

func NewUseSearcher(
	pkgs []*packages.Package,
	refSearcher RefPkgSearcher,
	objExtractor ObjExtractor,
	tgtExtractor TargetExtractor,
	fieldSearcher FieldSearcher,
	defSetFilter Filter,
	opt ...UseSearcherOption,
) UseSearcher

type UseSearcherConfig

type UseSearcherConfig struct {
	// contains filtered or unexported fields
}

type UseSearcherOption

type UseSearcherOption func(*UseSearcherConfig)

func WithUseSearcherIgnorePkgSelfloop

func WithUseSearcherIgnorePkgSelfloop(v bool) UseSearcherOption

func WithUseSearcherIgnoreUseSelfloop

func WithUseSearcherIgnoreUseSelfloop(v bool) UseSearcherOption

func WithUseSearcherObjNameRegexp

func WithUseSearcherObjNameRegexp(v util.RegexpPair) UseSearcherOption

func WithUseSearcherPkgNameRegexp

func WithUseSearcherPkgNameRegexp(v util.RegexpPair) UseSearcherOption

func WithUseSearcherResultBufferSize

func WithUseSearcherResultBufferSize(v int) UseSearcherOption

func WithUseSearcherSearchForeign

func WithUseSearcherSearchForeign(v bool) UseSearcherOption

func WithUseSearcherSearchPrivate

func WithUseSearcherSearchPrivate(v bool) UseSearcherOption

func WithUseSearcherSearchUniverse

func WithUseSearcherSearchUniverse(v bool) UseSearcherOption

func WithUseSearcherWorkerNum

func WithUseSearcherWorkerNum(v int) UseSearcherOption

Directories

Path Synopsis
sub

Jump to

Keyboard shortcuts

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