typ

package
v4.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Unlicense Imports: 7 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 struct {
	Type          *ast.TypeSpec
	PkgName       string
	PkgPath       string
	ImportAliased bool
}

A Dependency is a struct containing a package and a dependent type spec.

func (Dependency) Name

func (d Dependency) Name() string

type Dir

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

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

func (Dir) Dependencies

func (d Dir) Dependencies(name string) []Dependency

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

func (Dir) Dir

func (d Dir) Dir() string

Dir returns the directory path that d represents.

func (Dir) ExportedTypes

func (d Dir) ExportedTypes() []*ast.TypeSpec

ExportedTypes returns all *ast.TypeSpecs found by d. Interface types with anonymous interface types will be flattened, for ease of mocking by other logic.

func (Dir) Filter

func (d Dir) Filter(matchers ...*regexp.Regexp) Dir

Filter filters d's types, removing all types that don't match any of the passed in matchers.

func (Dir) Len

func (d Dir) Len() int

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

func (Dir) Package

func (d Dir) Package() string

Package returns the name of d's importable package.

type Dirs

type Dirs []Dir

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

func Load

func Load(goDirs ...GoDir) Dirs

Load loads a Dirs value for goDirs.

func (Dirs) Filter

func (d Dirs) Filter(patterns ...string) (dirs Dirs)

Filter calls Dir.Filter for each Dir in d.

type GoDir

type GoDir interface {
	Path() (path string)
	Package() *packages.Package
	Import(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