types

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: BSD-3-Clause Imports: 25 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &command.Command{
	Run:       runTypes,
	UsageLine: "types",
	Short:     "golang type util",
	Long:      `golang type util`,
}
View Source
var ObjKindName = []string{"none", "package", "package",
	"type", "interface", "struct",
	"const", "var", "field",
	"func", "method",
	"label", "builtin", "nil",
	"implicit", "unknown", "comment"}

Functions

func IsSameObject

func IsSameObject(a, b types.Object, kind ObjKind) bool

func IsSamePkg

func IsSamePkg(a, b *types.Package) bool

Types

type ExprSlice added in v1.1.0

type ExprSlice []ast.Expr

func (ExprSlice) Len added in v1.1.0

func (p ExprSlice) Len() int

func (ExprSlice) Less added in v1.1.0

func (p ExprSlice) Less(i, j int) bool

func (ExprSlice) Swap added in v1.1.0

func (p ExprSlice) Swap(i, j int)

type FileCursor

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

func NewFileCursor

func NewFileCursor(src []byte, dir string, filename string, pos int) *FileCursor

func (*FileCursor) SetText

func (f *FileCursor) SetText(text string)

type FilesCheck

type FilesCheck struct {
	HashSum [16]byte
	ModTime int64
}

type FindMode

type FindMode struct {
	Info        bool
	Doc         bool
	Define      bool
	Usage       bool
	UsageAll    bool
	Import      bool
	ImportRange bool
	SkipGoroot  bool
}

func (*FindMode) IsValid

func (f *FindMode) IsValid() bool

type Importer

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

func (*Importer) Import

func (im *Importer) Import(name string) (pkg *types.Package, err error)

type ObjKind

type ObjKind int
const (
	ObjNone ObjKind = iota
	ObjPackage
	ObjPkgName
	ObjTypeName
	ObjInterface
	ObjStruct
	ObjConst
	ObjVar
	ObjField
	ObjFunc
	ObjMethod
	ObjLabel
	ObjBuiltin
	ObjNil
	ObjImplicit
	ObjUnknown
	ObjComment
)

func (ObjKind) String

func (k ObjKind) String() string

type ObjectInfo added in v1.1.0

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

type PkgConfig

type PkgConfig struct {
	Pkg              *types.Package
	XPkg             *types.Package
	Info             *types.Info
	XInfo            *types.Info
	Bpkg             *build.Package
	Files            map[string]*ast.File
	XTestFiles       map[string]*ast.File
	IgnoreFuncBodies bool
	AllowBinary      bool
	WithTestFiles    bool
}

func DefaultPkgConfig

func DefaultPkgConfig() *PkgConfig

func NewPkgConfig

func NewPkgConfig(ignoreFuncBodies bool, withTestFiles bool) *PkgConfig

type PkgWalker

type PkgWalker struct {
	FileSet *token.FileSet
	Context *build.Context

	ParsedFileCache   map[string]*ast.File
	ParsedFileModTime map[string]int64

	Imported           map[string]*types.Package // packages already imported
	ImportedConfig     map[string]*PkgConfig
	ImportedFilesCheck map[string]*FilesCheck

	Mod *gomod.Package
	// contains filtered or unexported fields
}

func NewPkgWalker

func NewPkgWalker(context *build.Context) *PkgWalker

func (*PkgWalker) Check

func (p *PkgWalker) Check(name string, conf *PkgConfig, cusror *FileCursor) (pkg *types.Package, outconf *PkgConfig, err error)

func (*PkgWalker) CheckIsBasic added in v1.1.0

func (w *PkgWalker) CheckIsBasic(cursor *FileCursor, pkgInfo *types.Info) *ast.BasicLit

func (*PkgWalker) CheckIsImport

func (w *PkgWalker) CheckIsImport(cursor *FileCursor) *ast.ImportSpec

func (*PkgWalker) CheckIsName

func (w *PkgWalker) CheckIsName(cursor *FileCursor) *ast.Ident

func (*PkgWalker) CheckIsObject added in v1.1.0

func (w *PkgWalker) CheckIsObject(cursor *FileCursor, pkgInfo *types.Info) (cursorObj types.Object, cursorSelection *types.Selection)

func (*PkgWalker) CheckObjectInfo added in v1.1.0

func (w *PkgWalker) CheckObjectInfo(cursorObj types.Object, cursorSelection *types.Selection, kind ObjKind, pkg *types.Package, pkgInfo *types.Info) *ObjectInfo

func (*PkgWalker) Import

func (w *PkgWalker) Import(parentDir string, name string, conf *PkgConfig, cursor *FileCursor) (pkg *types.Package, outconf *PkgConfig, err error)

func (*PkgWalker) ImportHelper

func (w *PkgWalker) ImportHelper(parentDir string, name string, import_path string, conf *PkgConfig, cursor *FileCursor) (pkg *types.Package, outconf *PkgConfig, err error)

func (*PkgWalker) LookupByText

func (w *PkgWalker) LookupByText(pkgInfo *types.Info, text string) types.Object

func (*PkgWalker) LookupCursor

func (w *PkgWalker) LookupCursor(pkg *types.Package, conf *PkgConfig, cursor *FileCursor) error

func (*PkgWalker) LookupImport

func (w *PkgWalker) LookupImport(pkg *types.Package, pkgInfo *types.Info, cursor *FileCursor, is *ast.ImportSpec) error

func (*PkgWalker) LookupName

func (w *PkgWalker) LookupName(pkg *types.Package, conf *PkgConfig, cursor *FileCursor, nm *ast.Ident) error

func (*PkgWalker) LookupObjects

func (w *PkgWalker) LookupObjects(conf *PkgConfig, cursor *FileCursor) error

func (*PkgWalker) LookupStructFromField

func (w *PkgWalker) LookupStructFromField(info *types.Info, cursorPkg *types.Package, cursorObj types.Object, cursorPos token.Pos) types.Object

func (*PkgWalker) SetFindMode

func (w *PkgWalker) SetFindMode(mode *FindMode)

func (*PkgWalker) SetOutput

func (w *PkgWalker) SetOutput(stdout io.Writer, stderr io.Writer)

func (*PkgWalker) UpdateSourceData

func (w *PkgWalker) UpdateSourceData(filename string, data []byte, cleanAllSourceCache bool)

type SourceData

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

Jump to

Keyboard shortcuts

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