Documentation
¶
Index ¶
- func ApplyBaseRewrites(packages []*packages.Package)
- func AstFileToBytes(fset *token.FileSet, file *ast.File) ([]byte, error)
- func ForEachPackageIncludingDependencies(pkgs []*packages.Package, fn func(*packages.Package))
- func FreshVar(p *types.Package, scope *types.Scope, base string, t types.Type) *types.Var
- func TypeNameForGeneration(t types.Type) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyBaseRewrites ¶
ApplyBaseRewrites applies a series of rewrite steps to the packages and all its dependencies. The rewrites are:
- calls to sort.Slice and sort.SliceStable are removed and replaced by calls to the functions used in sorting. - calls to (sync.Once).Do are replaced by a call to the method in the sync.Once object.
func AstFileToBytes ¶
AstFileToBytes pretty prints an AST file to a slice of byte.
func ForEachPackageIncludingDependencies ¶
ForEachPackageIncludingDependencies calls fn exactly once for each package that is in pkgs or in the transitive dependencies of pkgs.
func FreshVar ¶
FreshVar generates a fresh variable in the given scope, with a base name and a type. If the base name already exists in the scope, then the function attempts to look for names of the form "<base name>_<i>" where i is incremented until the id is not in scope. The function updates the scope when it returns a new `*types.Var`. This ensures that any future calls to FreshVar in the same scope will return a fresh variable again.
func TypeNameForGeneration ¶
TypeNameForGeneration recursively decomposes the type to find a type.Named to use for variable name generation. This is a heuristic that could potentially generate names that are easier for debugging purposes.
This shouldn't be relied on as the sole mechanism to generate variable names. The caller is responsible for checking that the name is not already defined in the scope when a fresh variable name is required.
Types ¶
This section is empty.