typ

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Unlicense Imports: 11 Imported by: 0

Documentation

Overview

Package types contains logic for parsing type definitions from ast packages and filtering those types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependency

type Dependency interface {
	Name() string
	TypeName() string
	PkgPath() string
	PkgName() string
	ImportAliased() bool
	Type() ast.Expr
	Params() []*ast.Field
	AvoidCollision(ctx context.Context, name string) dep.Dependency
	FromPkg(ctx context.Context, name, path string) dep.Dependency
}

Dependency is a type for tracking dependencies of local logic.

type Dir

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

A Dir is a type that represents a directory containing Go packages.

func (*Dir) Clone

func (d *Dir) Clone(ctx context.Context) *Dir

Clone returns a copy of d.

func (*Dir) Decls

func (d *Dir) Decls(ctx context.Context) []ast.Decl

Decls returns all ast.Decl (declarations) found by d. Interface types with anonymous interface types will be flattened, for ease of mocking by other logic.

This includes unexported declaratiions.

func (*Dir) Dependencies

func (d *Dir) Dependencies(ctx context.Context, name string) []Dependency

Dependencies returns all interface types that typ depends on for method parameters or results.

func (*Dir) Dir

func (d *Dir) Dir(ctx context.Context) string

Dir returns the directory path that d represents.

func (*Dir) Filter

func (d *Dir) Filter(ctx context.Context, matchers ...*regexp.Regexp) *Dir

Filter returns a copy of d with all types filtered. All types in the returned Dir will match at least one of the passed in matchers.

func (*Dir) Len

func (d *Dir) Len(ctx context.Context) int

Len returns the number of types that will be returned by d.ExportedDecls().

func (*Dir) Package

func (d *Dir) Package(ctx context.Context) string

Package returns the name of d's importable package.

type Dirs

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

Dirs is a slice of Dir values, to provide sugar for running some methods against multiple Dir values.

func Load

func Load(ctx context.Context, unexported bool, goDirs ...GoDir) Dirs

Load loads a Dirs value for goDirs.

func (Dirs) Filter

func (d Dirs) Filter(ctx context.Context, patterns ...string) Dirs

Filter calls Dir.Filter for each Dir in d.

func (Dirs) Slice

func (d Dirs) Slice(ctx context.Context) []*Dir

Slice returns the Dir values contained in d in slice form.

type GoDir

type GoDir interface {
	Path(context.Context) (path string)
	Package(context.Context) *packages.Package
	Import(ctx context.Context, path string) (*packages.Package, error)
}

A GoDir is a type that represents a directory of Go files.

Jump to

Keyboard shortcuts

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