Documentation
¶
Index ¶
- type MethodScope
- type Package
- type Registry
- func (r *Registry) AddImport(pkg *types.Package) *Package
- func (r Registry) Imports() []*Package
- func (r Registry) LookupInterface(name string) (*types.Interface, *types.TypeParamList, error)
- func (r *Registry) MethodScope() *MethodScope
- func (r Registry) SrcPkg() *types.Package
- func (r Registry) SrcPkgName() string
- type Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MethodScope ¶
type MethodScope struct {
// contains filtered or unexported fields
}
MethodScope is the sub-registry for allocating variables present in the method scope.
It should be created using a registry instance.
func (*MethodScope) AddVar ¶
func (m *MethodScope) AddVar(vr *types.Var, suffix string) *Var
AddVar allocates a variable instance and adds it to the method scope.
Variables names are generated if required and are ensured to be without conflict with other variables and imported packages. It also adds the relevant imports to the registry for each added variable.
type Package ¶
type Package struct { Alias string // contains filtered or unexported fields }
Package represents an imported package.
func NewPackage ¶
NewPackage creates a new instance of Package.
func (*Package) Path ¶
Path is the full package import path (without vendor).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry encapsulates types information for the source and mock destination package. For the mock package, it tracks the list of imports and ensures there are no conflicts in the imported package qualifiers.
func New ¶
New loads the source package info and returns a new instance of Registry.
func (*Registry) AddImport ¶
AddImport adds the given package to the set of imports. It generates a suitable alias if there are any conflicts with previously imported packages.
func (Registry) Imports ¶
Imports returns the list of imported packages. The list is sorted by path.
func (Registry) LookupInterface ¶
LookupInterface returns the underlying interface definition of the given interface name.
func (*Registry) MethodScope ¶
func (r *Registry) MethodScope() *MethodScope
MethodScope returns a new MethodScope.
func (Registry) SrcPkg ¶
SrcPkg returns the types info for the source package.