filters

package
v3.0.0-...-cfbdf18 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Declarations

func Declarations(decls []ast.Decl, predicate func(decl ast.Decl) bool) (filtered []ast.Decl)

Declarations takes in a list of a declarations and a predicate that takes in one declaration and returns a boolean. Only the declarations for which `predicate` returns true will be included in the returned list of declarations.

For example, the following returns a list of only function declarations.

filters.Declarations(tree.Decls, func(decl ast.Decl) bool {
	_, ok := decl.(*ast.FuncDecl)
	return ok
})

The order of declarations is maintained.

func FunctionsOnly

func FunctionsOnly(decls []ast.Decl) []ast.Decl

FunctionsOnly returns a list of only the most outer function declarations present within the provided list. This filter does NOT recurse into those function declarations to find lambdas. For example, the following file...

func hi() bool {
	return func() bool {
		return true
	}()
}

func hello() bool {
	return false
}

...will return the hi and hello functions but not the inner lambda within hi.

func IsAGoFile

func IsAGoFile(file *lint.File) bool

func IsALint

func IsALint(file *lint.File) bool

func IsATest

func IsATest(file *lint.File) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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