Documentation
¶
Overview ¶
Package stubmethods provides the analysis logic for the quick fix to "Declare missing methods of TYPE" errors. (The fix logic lives in golang.stubMethodsFixer.)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallStubInfo ¶
type CallStubInfo struct {
Fset *token.FileSet // the FileSet used to type-check the types below
Receiver typesinternal.NamedOrAlias // the method's receiver type
MethodName string
// contains filtered or unexported fields
}
CallStubInfo represents a missing method that a receiver type is about to generate which has "type X has no field or method Y" error
type IfaceStubInfo ¶
type IfaceStubInfo struct {
// Interface is the interface that the client wants to implement.
// When the interface is defined, the underlying object will be a TypeName.
// Note that we keep track of types.Object instead of types.Type in order
// to keep a reference to the declaring object's package and the ast file
// in the case where the concrete type file requires a new import that happens to be renamed
// in the interface file.
// TODO(marwan-at-work): implement interface literals.
Fset *token.FileSet // the FileSet used to type-check the types below
Interface *types.TypeName
Concrete typesinternal.NamedOrAlias
// contains filtered or unexported fields
}
IfaceStubInfo represents a concrete type that wants to stub out an interface type
func GetIfaceStubInfo ¶
func GetIfaceStubInfo(fset *token.FileSet, info *types.Info, path []ast.Node, pos token.Pos) *IfaceStubInfo
GetIfaceStubInfo determines whether the "missing method error" can be used to deduced what the concrete and interface types are.
TODO(adonovan): this function (and its following 5 helpers) tries to deduce a pair of (concrete, interface) types that are related by an assignment, either explicitly or through a return statement or function call. This is essentially what the refactor/satisfy does, more generally. Refactor to share logic, after auditing 'satisfy' for safety on ill-typed code.