locateutil

package
v0.0.0-...-43c8ab9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

Package cloudeng.io/go/locate/locateutil

CircleCI Go Report Card

import cloudeng.io/go/locate/locateutil

Package locateutil provides utility routines for use with its parent locate package.

Functions

Func CommentGroupBounds
func CommentGroupBounds(comments []*ast.CommentGroup) (first, last token.Pos)

CommentGroupBounds returns the lowest and largest token.Pos of any of the supplied CommentGroups.

Func CommentGroupsContain
func CommentGroupsContain(comments []*ast.CommentGroup, text string) bool

CommentGroupsContain returns if any of the supplied CommentGroups contain 'text'.

Func FunctionCalls
func FunctionCalls(decl *ast.FuncDecl, callname *regexp.Regexp, deferred bool) []ast.Node

FunctionCalls determines if the supplied function declaration contains a call 'callname' where callname is either a function name or a selector (eg. foo.bar). If deferred is true the function call must be defer'ed.

Func FunctionHasComment
func FunctionHasComment(decl *ast.FuncDecl, cmap ast.CommentMap, text string) bool

FunctionHasComment returns true if any of the comments associated or within the function contain the specified text.

Func FunctionStatements
func FunctionStatements(decl *ast.FuncDecl) int

FunctionStatements returns number of top-level statements in a function.

Func ImportBlock
func ImportBlock(file *ast.File) (start, end token.Pos)

ImportBlock returns the start and end positions of an import statement or import block for the supplied file.

Func InterfaceType
func InterfaceType(typ types.Type) *types.Interface

InterfaceType returns the underlying *types.Interface if typ represents an interface or nil otherwise.

Func IsAbstract
func IsAbstract(fn *types.Func) bool

IsAbstract returns true if the function declaration is abstract.

Func IsImportedByFile
func IsImportedByFile(file *ast.File, path string) bool

IsImportedByFile returns true if the supplied path appears in the Imports section of an ast.File.

Func IsInterfaceDefinition
func IsInterfaceDefinition(pkg *packages.Package, obj types.Object) *types.Interface

IsInterfaceDefinition returns the interface type that the suplied object defines in the specified package, if any. This specifically excludes embedded types which are defined in other packages and anonymous interfaces.

Types

Type FuncDesc
type FuncDesc struct {
	Type     *types.Func
	Abstract bool
	Decl     *ast.FuncDecl
	File     *ast.File
	Position token.Position
	Package  *packages.Package
}

FuncDesc represents a function definition, declaration and the file and position within that file. Decl will be nil if Abstract is true.

Functions
func Functions(pkg *packages.Package, re *regexp.Regexp, noMethods bool) []FuncDesc

Functions returns the functions in the supplied package that match the regular expression. If noMethods is false then methods are also returned.

Documentation

Overview

Package locateutil provides utility routines for use with its parent locate package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommentGroupBounds

func CommentGroupBounds(comments []*ast.CommentGroup) (first, last token.Pos)

CommentGroupBounds returns the lowest and largest token.Pos of any of the supplied CommentGroups.

func CommentGroupsContain

func CommentGroupsContain(comments []*ast.CommentGroup, text string) bool

CommentGroupsContain returns if any of the supplied CommentGroups contain 'text'.

func FunctionCalls

func FunctionCalls(decl *ast.FuncDecl, callname *regexp.Regexp, deferred bool) []ast.Node

FunctionCalls determines if the supplied function declaration contains a call 'callname' where callname is either a function name or a selector (eg. foo.bar). If deferred is true the function call must be defer'ed.

func FunctionHasComment

func FunctionHasComment(decl *ast.FuncDecl, cmap ast.CommentMap, text string) bool

FunctionHasComment returns true if any of the comments associated or within the function contain the specified text.

func FunctionStatements

func FunctionStatements(decl *ast.FuncDecl) int

FunctionStatements returns number of top-level statements in a function.

func ImportBlock

func ImportBlock(file *ast.File) (start, end token.Pos)

ImportBlock returns the start and end positions of an import statement or import block for the supplied file.

func InterfaceType

func InterfaceType(typ types.Type) *types.Interface

InterfaceType returns the underlying *types.Interface if typ represents an interface or nil otherwise.

func IsAbstract

func IsAbstract(fn *types.Func) bool

IsAbstract returns true if the function declaration is abstract.

func IsImportedByFile

func IsImportedByFile(file *ast.File, path string) bool

IsImportedByFile returns true if the supplied path appears in the Imports section of an ast.File.

func IsInterfaceDefinition

func IsInterfaceDefinition(pkg *packages.Package, obj types.Object) *types.Interface

IsInterfaceDefinition returns the interface type that the suplied object defines in the specified package, if any. This specifically excludes embedded types which are defined in other packages and anonymous interfaces.

Types

type FuncDesc

type FuncDesc struct {
	Type     *types.Func
	Abstract bool
	Decl     *ast.FuncDecl
	File     *ast.File
	Position token.Position
	Package  *packages.Package
}

FuncDesc represents a function definition, declaration and the file and position within that file. Decl will be nil if Abstract is true.

func Functions

func Functions(pkg *packages.Package, re *regexp.Regexp, noMethods bool) []FuncDesc

Functions returns the functions in the supplied package that match the regular expression. If noMethods is false then methods are also returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL