ifacereader

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ifacereader reads the specified interfaces, returning their listed methods.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoInterfaces     = erk.New(ErkInvalidInput{}, "No interfaces provided for path '{{.path}}'. Please provide which interfaces to mock.")
	ErrDuplicatePath    = erk.New(ErkInvalidInput{}, "Duplicate entry for path '{{.path}}'. Please combine both entries and list multiple interfaces instead.")
	ErrLoadingPackages  = erk.New(ErkInvalidInput{}, "Unable to load all packages: {{.err}}")
	ErrReadingPackage   = erk.New(ErkInvalidInput{}, "Error reading package '{{.path}}'")
	ErrInvalidInterface = erk.New(ErkInvalidInput{}, "Interface '{{.interface}}' not found in package: {{.package}}")
	ErrNotInterface     = erk.New(ErkInvalidInput{}, "Type '{{.interface}}' is not an interface in package '{{.package}}', it's a '{{.type}}'")

	ErrPathMismatch           = erk.New(ErkInternal{}, unexpectedErrorPrefix+": Could not find package details for path: {{.path}}")
	ErrLeftoverPackageDetails = erk.New(ErkInternal{}, unexpectedErrorPrefix+": Unexpected leftover package details")
	ErrFuncUnderlyingType     = erk.New(ErkInternal{},
		unexpectedErrorPrefix+": *types.Func underlying type was not *types.Signature, it was: {{type .underlyingType}}",
	)
)

Functions

This section is empty.

Types

type ErkInternal

type ErkInternal struct{ erk.DefaultKind }

type ErkInvalidInput

type ErkInvalidInput struct{ erk.DefaultKind }

type Interface

type Interface struct {
	Name    string
	Methods []*Method
}

Interface includes the details of parsing the interface in the package.

type InterfaceReader

type InterfaceReader struct{}

InterfaceReader reads the specified interfaces, returning their listed methods.

func (*InterfaceReader) ReadPackages

func (r *InterfaceReader) ReadPackages(pkgDetails []*PackageDetails, pkgNameGen PackageNameGenerator) ([]*Package, error)

ReadPackages reads all the packages within the specified package and interface combinations.

type Method

type Method struct {
	Name    string
	Inputs  []*Tuple
	Outputs []*Tuple
}

Method includes the details of a single method inside of an interface.

type Package

type Package struct {
	Name       string
	Path       string
	Interfaces []*Interface
}

Package includes the details of parsing the interfaces in the package.

func (*Package) InterfaceNames

func (pkg *Package) InterfaceNames() []string

InterfaceNames extracts each of the interface names for which to generate mocks.

type PackageDetails

type PackageDetails struct {
	Path       string
	Interfaces []string
}

PackageDetails provides the package path and interfaces to the ReadPackages method.

type PackageNameGenerator

type PackageNameGenerator interface {
	GeneratePackageName(scopePackage *packages.Package, importedPackage *types.Package) string
}

PackageNameGenerator allows generating a package name for a type given the current package and the imported package.

type Readable

type Readable interface {
	ReadPackages(pkgDetails []*PackageDetails, pkgNameGen PackageNameGenerator) ([]*Package, error)
}

Readable reads the specified interfaces, returning their listed methods.

type Tuple

type Tuple struct {
	VariableName string
	Type         string
	Variadic     bool
}

Tuple includes the details of a single input or output parameter in a method signature.

Jump to

Keyboard shortcuts

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