Documentation ¶
Index ¶
- func CompliesGetter(m *types.Func) bool
- func CompliesStringer(src types.Type) bool
- func Deref(typ types.Type) (types.Type, bool)
- func DerefPtr(typ types.Type) types.Type
- func ExtractMatchComments(commentGroup *ast.CommentGroup, pattern *regexp.Regexp) []*ast.Comment
- func FindField(t types.Type, name string, exactCase bool) (field *types.Var)
- func FindMethod(t types.Type, name string, exactCase bool) (method *types.Func)
- func GetDocCommentOn(file *ast.File, obj types.Object) (cg *ast.CommentGroup, cleanUp func())
- func GetMethodReturnTypes(m *types.Func) (*types.Tuple, bool)
- func InsertComment(file *ast.File, text string, pos token.Pos)
- func IsBasicType(t types.Type) bool
- func IsErrorType(t types.Type) bool
- func IsFunc(obj types.Object) bool
- func IsInvalidType(t types.Type) bool
- func IsNamedType(t types.Type) bool
- func IsPtr(t types.Type) bool
- func IsSliceType(t types.Type) bool
- func IsStructType(t types.Type) bool
- func IterateFields(t types.Type, cb func(*types.Var) (done bool))
- func IterateMethods(t types.Type, cb func(*types.Func) (done bool))
- func MatchComments(commentGroup *ast.CommentGroup, pattern *regexp.Regexp) bool
- func ParseGetterReturnTypes(m *types.Func) (ret types.Type, retError, ok bool)
- func PathMatch(pattern, name string, exactCase bool) (bool, error)
- func PkgOf(t types.Type) *types.Package
- func RemoveDecl(file *ast.File, name string)
- func RemoveMatchComments(file *ast.File, pattern *regexp.Regexp)
- func SliceElement(t types.Type) types.Type
- func StringType() types.Type
- func ToAstNode(file *ast.File, obj types.Object) (path []ast.Node, exact bool)
- func ToTextList(doc *ast.CommentGroup) []string
- type ImportNames
- type LookupFieldOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompliesGetter ¶
CompliesGetter checks whether the given function complies with the requirements of a getter function. A getter function must have no input parameters and must return exactly one non-error value.
func CompliesStringer ¶
CompliesStringer checks if the given type is a Stringer compliant type, which has a method "String()" that takes no arguments and returns a string.
func Deref ¶
Deref dereferences a type if it is a *Pointer type and returns its base type and true. Otherwise, it returns (typ, false).
func ExtractMatchComments ¶
ExtractMatchComments removes pattern matched comments from commentGroup and returns them.
func FindMethod ¶
FindMethod returns the method with the given name in the given type.
func GetDocCommentOn ¶
GetDocCommentOn retrieves doc comments that relate to nodes.
func GetMethodReturnTypes ¶
GetMethodReturnTypes returns the return types of the given method.
func InsertComment ¶
InsertComment inserts a comment with the specified text at the specified position in file.Comments.
func IsBasicType ¶
IsBasicType returns true if the given type is a basic type.
func IsErrorType ¶
IsErrorType returns true if the given type is an error type.
func IsInvalidType ¶
IsInvalidType returns true if the given type is an invalid type.
func IsNamedType ¶
IsNamedType returns true if the given type is a named type.
func IsSliceType ¶
IsSliceType returns true if the given type is a slice type.
func IsStructType ¶
IsStructType returns true if the given type is a struct type.
func IterateFields ¶
IterateFields iterates over the fields of the given type and calls the callback for each one.
func IterateMethods ¶
IterateMethods iterates over the methods of the given type and calls the callback for each one.
func MatchComments ¶
func MatchComments(commentGroup *ast.CommentGroup, pattern *regexp.Regexp) bool
MatchComments reports whether any comment line in commentGroup contains any match of the regular expression pattern.
func ParseGetterReturnTypes ¶
ParseGetterReturnTypes returns the return types of the given method.
func RemoveDecl ¶
RemoveDecl removes a declaration named name from file.Decls.
func RemoveMatchComments ¶
RemoveMatchComments removes pattern matched comments from file.Comments.
func SliceElement ¶
SliceElement returns the type of the element in a slice type.
func StringType ¶
StringType returns the string type in the universe scope.
func ToTextList ¶
func ToTextList(doc *ast.CommentGroup) []string
ToTextList returns a list of strings representing the comments in a CommentGroup.
Types ¶
type ImportNames ¶
ImportNames is a map of a package path to a package name in a convergen setup file.
func NewImportNames ¶
func NewImportNames(specs []*ast.ImportSpec) ImportNames
NewImportNames creates a new ImportNames instance.
func (ImportNames) IsExternal ¶
func (i ImportNames) IsExternal(t types.Type) bool
IsExternal returns true if the given type is defined in a different package than the conversion setup file.
func (ImportNames) LookupName ¶
func (i ImportNames) LookupName(pkgPath string) (name string, ok bool)
LookupName looks up the map with the pkgPath and returns its corresponding name in the conversion setup file.
func (ImportNames) LookupPath ¶
func (i ImportNames) LookupPath(pkgName string) (path string, ok bool)
LookupPath looks up the map with the pkgName and returns its corresponding path in the conversion setup file.