Documentation ¶
Overview ¶
copied from github.com/google/wire/internal/wire
Index ¶
- func MatchObject(obj types.Object)
- func MatchType(typ types.Type)
- type DIContext
- type DefaultProcessConfigurer
- func (*DefaultProcessConfigurer) InjectorPredicate(fn *types.Func) bool
- func (*DefaultProcessConfigurer) ProviderElect(inj *comm.Injector, bean *comm.Bean, providers map[string]*comm.Provider) *comm.Provider
- func (*DefaultProcessConfigurer) ProviderPredicate(fn *types.Func) bool
- func (c *DefaultProcessConfigurer) WillRewriteSource() bool
- type Field
- type IfaceBinding
- type Info
- type Injector
- type InjectorArg
- type InjectorArgs
- type LoadConfig
- type LoadMode
- type ProcessConfigurer
- type ProvidedType
- func (pt ProvidedType) Arg() *InjectorArg
- func (pt ProvidedType) Field() *Field
- func (pt ProvidedType) IsArg() bool
- func (pt ProvidedType) IsField() bool
- func (pt ProvidedType) IsNil() bool
- func (pt ProvidedType) IsProvider() bool
- func (pt ProvidedType) IsValue() bool
- func (pt ProvidedType) Provider() *Provider
- func (pt ProvidedType) Type() types.Type
- func (pt ProvidedType) Value() *Value
- type Provider
- type ProviderInput
- type ProviderSet
- type ProviderSetID
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchObject ¶
Types ¶
type DIContext ¶
type DIContext struct {
// contains filtered or unexported fields
}
func NewDIContext ¶
func NewDIContext(conf ProcessConfigurer) *DIContext
type DefaultProcessConfigurer ¶
type DefaultProcessConfigurer struct {
// contains filtered or unexported fields
}
func (*DefaultProcessConfigurer) InjectorPredicate ¶
func (*DefaultProcessConfigurer) InjectorPredicate(fn *types.Func) bool
InjectorPredicate implements ProcessConfigurer
func (*DefaultProcessConfigurer) ProviderElect ¶
func (*DefaultProcessConfigurer) ProviderElect(inj *comm.Injector, bean *comm.Bean, providers map[string]*comm.Provider) *comm.Provider
ProviderElector implements ProcessConfigurer
func (*DefaultProcessConfigurer) ProviderPredicate ¶
func (*DefaultProcessConfigurer) ProviderPredicate(fn *types.Func) bool
ProviderPredicate implements ProcessConfigurer
func (*DefaultProcessConfigurer) WillRewriteSource ¶
func (c *DefaultProcessConfigurer) WillRewriteSource() bool
WillRewriteSource implements ProcessConfigurer
type Field ¶
type Field struct { // Parent is the struct or pointer to the struct that the field belongs to. Parent types.Type // Name is the field name. Name string // Pkg is the package that the struct resides in. Pkg *types.Package // Pos is the source position of the field declaration. // defining these fields. Pos token.Pos // Out is the field's provided types. The first element provides the // field type. If the field is coming from a pointer to a struct, // there will be a second element providing a pointer to the field. Out []types.Type }
Field describes a specific field selected from a struct.
type IfaceBinding ¶
type IfaceBinding struct { // Iface is the interface type, which is what can be injected. Iface types.Type // Provided is always a type that is assignable to Iface. Provided types.Type // Pos is the position where the binding was declared. Pos token.Pos }
An IfaceBinding declares that a type should be used to satisfy inputs of the given interface type.
type Info ¶
type Info struct { Fset *token.FileSet // Sets contains all the provider sets in the initial packages. Sets map[ProviderSetID]*ProviderSet // Injectors contains all the injector functions in the initial packages. // The order is undefined. Injectors []*Injector }
Info holds the result of Load.
type InjectorArg ¶
type InjectorArg struct { // Args is the full set of arguments. Args *InjectorArgs // Index is the index into Args.Tuple for this argument. Index int }
InjectorArg describes a specific argument passed to an injector function.
type InjectorArgs ¶
type InjectorArgs struct { // Name is the name of the injector function. Name string // Tuple represents the arguments. Tuple *types.Tuple // Pos is the source position of the injector function. Pos token.Pos }
InjectorArgs describes the arguments passed to an injector function.
type LoadConfig ¶
type LoadConfig struct {
LoadMode LoadMode
}
type ProcessConfigurer ¶
type ProcessConfigurer interface { // // whether to rewrite source code WillRewriteSource() bool // used to report whether a function is an injector // this is helpful when you only want to generate a part of functions in the package InjectorPredicate(fn *types.Func) bool // used to report whether a function can be provider ProviderPredicate(fn *types.Func) bool // used to find proper provider from multiple ones ProviderElect(inj *comm.Injector, bean *comm.Bean, providers map[string]*comm.Provider) *comm.Provider }
optional config when processing autowire
type ProvidedType ¶
type ProvidedType struct {
// contains filtered or unexported fields
}
ProvidedType represents a type provided from a source. The source can be a *Provider (a provider function), a *Value (wire.Value), or an *InjectorArgs (arguments to the injector function). The zero value has none of the above, and returns true for IsNil.
func (ProvidedType) Arg ¶
func (pt ProvidedType) Arg() *InjectorArg
Arg returns pt as an *InjectorArg representing an injector argument. It panics if pt does not point to an arg.
func (ProvidedType) Field ¶
func (pt ProvidedType) Field() *Field
Field returns pt as a Field pointer. It panics if pt does not point to a struct Field.
func (ProvidedType) IsArg ¶
func (pt ProvidedType) IsArg() bool
IsArg reports whether pt points to an injector argument.
func (ProvidedType) IsField ¶
func (pt ProvidedType) IsField() bool
IsField reports whether pt points to a Fields.
func (ProvidedType) IsNil ¶
func (pt ProvidedType) IsNil() bool
IsNil reports whether pt is the zero value.
func (ProvidedType) IsProvider ¶
func (pt ProvidedType) IsProvider() bool
IsProvider reports whether pt points to a Provider.
func (ProvidedType) IsValue ¶
func (pt ProvidedType) IsValue() bool
IsValue reports whether pt points to a Value.
func (ProvidedType) Provider ¶
func (pt ProvidedType) Provider() *Provider
Provider returns pt as a Provider pointer. It panics if pt does not point to a Provider.
func (ProvidedType) Type ¶
func (pt ProvidedType) Type() types.Type
Type returns the output type.
- For a function provider, this is the first return value type.
- For a struct provider, this is either the struct type or the pointer type whose element type is the struct type.
- For a value, this is the type of the expression.
- For an argument, this is the type of the argument.
func (ProvidedType) Value ¶
func (pt ProvidedType) Value() *Value
Value returns pt as a Value pointer. It panics if pt does not point to a Value.
type Provider ¶
type Provider struct { // Pkg is the package that the Go object resides in. Pkg *types.Package // Name is the name of the Go object. Name string // Pos is the source position of the func keyword or type spec // defining this provider. Pos token.Pos // Args is the list of data dependencies this provider has. Args []ProviderInput // Varargs is true if the provider function is variadic. Varargs bool // IsStruct is true if this provider is a named struct type. // Otherwise it's a function. IsStruct bool // Out is the set of types this provider produces. It will always // contain at least one type. Out []types.Type // HasCleanup reports whether the provider function returns a cleanup // function. (Always false for structs.) HasCleanup bool // HasErr reports whether the provider function can return an error. // (Always false for structs.) HasErr bool }
Provider records the signature of a provider. A provider is a single Go object, either a function or a named struct type.
type ProviderInput ¶
type ProviderInput struct { Type types.Type // If the provider is a struct, FieldName will be the field name to set. FieldName string }
ProviderInput describes an incoming edge in the provider graph.
type ProviderSet ¶
type ProviderSet struct { // Pos is the position of the call to wire.NewSet or wire.Build that // created the set. Pos token.Pos // PkgPath is the import path of the package that declared this set. PkgPath string // VarName is the variable name of the set, if it came from a package // variable. VarName string Providers []*Provider Bindings []*IfaceBinding Values []*Value Fields []*Field Imports []*ProviderSet // InjectorArgs is only filled in for wire.Build. InjectorArgs *InjectorArgs // contains filtered or unexported fields }
A ProviderSet describes a set of providers. The zero value is an empty ProviderSet.
func (*ProviderSet) For ¶
func (set *ProviderSet) For(t types.Type) ProvidedType
For returns a ProvidedType for the given type, or the zero ProvidedType.
func (*ProviderSet) Outputs ¶
func (set *ProviderSet) Outputs() []types.Type
Outputs returns a new slice containing the set of possible types the provider set can produce. The order is unspecified.
type ProviderSetID ¶
A ProviderSetID identifies a named provider set.
func (ProviderSetID) String ¶
func (id ProviderSetID) String() string
String returns the ID as ""path/to/pkg".Foo".