go/src/go/ast/filter.go

// exportFilter is a special filter function to extract exported nodes.
func exportFilter(name string) bool {}

// FileExports trims the AST for a Go source file in place such that
// only exported nodes remain: all top-level identifiers which are not exported
// and their associated information (such as type, initial value, or function
// body) are removed. Non-exported fields and methods of exported types are
// stripped. The [File.Comments] list is not changed.
//
// FileExports reports whether there are exported declarations.
func FileExports(src *File) bool {}

// PackageExports trims the AST for a Go package in place such that
// only exported nodes remain. The pkg.Files list is not changed, so that
// file names and top-level package comments don't get lost.
//
// PackageExports reports whether there are exported declarations;
// it returns false otherwise.
func PackageExports(pkg *Package) bool {}

type Filter

func filterIdentList(list []*Ident, f Filter) []*Ident {}

// fieldName assumes that x is the type of an anonymous field and
// returns the corresponding field name. If x is not an acceptable
// anonymous field, the result is nil.
func fieldName(x Expr) *Ident {}

func filterFieldList(fields *FieldList, filter Filter, export bool) (removedFields bool) {}

func filterCompositeLit(lit *CompositeLit, filter Filter, export bool) {}

func filterExprList(list []Expr, filter Filter, export bool) []Expr {}

func filterParamList(fields *FieldList, filter Filter, export bool) bool {}

func filterType(typ Expr, f Filter, export bool) bool {}

func filterSpec(spec Spec, f Filter, export bool) bool {}

func filterSpecList(list []Spec, f Filter, export bool) []Spec {}

// FilterDecl trims the AST for a Go declaration in place by removing
// all names (including struct field and interface method names, but
// not from parameter lists) that don't pass through the filter f.
//
// FilterDecl reports whether there are any declared names left after
// filtering.
func FilterDecl(decl Decl, f Filter) bool {}

func filterDecl(decl Decl, f Filter, export bool) bool {}

// FilterFile trims the AST for a Go file in place by removing all
// names from top-level declarations (including struct field and
// interface method names, but not from parameter lists) that don't
// pass through the filter f. If the declaration is empty afterwards,
// the declaration is removed from the AST. Import declarations are
// always removed. The [File.Comments] list is not changed.
//
// FilterFile reports whether there are any top-level declarations
// left after filtering.
func FilterFile(src *File, f Filter) bool {}

func filterFile(src *File, f Filter, export bool) bool {}

// FilterPackage trims the AST for a Go package in place by removing
// all names from top-level declarations (including struct field and
// interface method names, but not from parameter lists) that don't
// pass through the filter f. If the declaration is empty afterwards,
// the declaration is removed from the AST. The pkg.Files list is not
// changed, so that file names and top-level package comments don't get
// lost.
//
// FilterPackage reports whether there are any top-level declarations
// left after filtering.
func FilterPackage(pkg *Package, f Filter) bool {}

func filterPackage(pkg *Package, f Filter, export bool) bool {}

type MergeMode

const FilterFuncDuplicates

const FilterUnassociatedComments

const FilterImportDuplicates

// nameOf returns the function (foo) or method name (foo.bar) for
// the given function declaration. If the AST is incorrect for the
// receiver, it assumes a function instead.
func nameOf(f *FuncDecl) string {}

var separator

// MergePackageFiles creates a file AST by merging the ASTs of the
// files belonging to a package. The mode flags control merging behavior.
func MergePackageFiles(pkg *Package, mode MergeMode) *File {}