var anyType … type CallStubInfo … // GetCallStubInfo extracts necessary information to generate a method definition from // a CallExpr. func GetCallStubInfo(fset *token.FileSet, info *types.Info, path []ast.Node, pos token.Pos) *CallStubInfo { … } // Emit writes to out the missing method based on type info of si.Receiver and CallExpr. func (si *CallStubInfo) Emit(out *bytes.Buffer, qual types.Qualifier) error { … } type param … // collectParams gathers the parameter information needed to generate a method stub. // The param's type default to any if there is a type error in the argument. func (si *CallStubInfo) collectParams() []param { … } // typesFromContext returns the type (or perhaps zero or multiple types) // of the "hole" into which the expression identified by path must fit. // // For example, given // // s, i := "", 0 // s, i = EXPR // // the hole that must be filled by EXPR has type (string, int). // // It returns nil on failure. func typesFromContext(info *types.Info, path []ast.Node, pos token.Pos) []types.Type { … } // parentNode returns the nodes immediately enclosing path[0], // ignoring parens. func parentNode(path []ast.Node) ast.Node { … } // containsInvalid checks if the type name contains "invalid type", // which is not a valid syntax to generate. func containsInvalid(t types.Type) bool { … } // paramName heuristically chooses a parameter name from // its argument expression and type. Caller should ensure // typ is non-nil. func paramName(e ast.Expr, typ types.Type) string { … } // lastSection find the position of the last uppercase letter, // extract the substring from that point onward, // and convert it to lowercase. // // Example: lastSection("registryManagerFactory") = "factory" func lastSection(identName string) string { … }