Documentation ¶
Index ¶
- func AssertEqualAstFile(want, got *ast.File) bool
- type AstFile
- func (a *AstFile) ChangePackage(newPkg string) error
- func (a *AstFile) ContainsFunc(fn string) bool
- func (a *AstFile) GetFuncDecl(fn string) *ast.FuncDecl
- func (a AstFile) SaveTemp(file string) (outFile string, cleaner func(), err error)
- func (a AstFile) String() string
- func (a *AstFile) SwapSimpleFuncs(fn1, fn2 string, strict bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEqualAstFile ¶
Assert two ASTs are structurally equivalent
Types ¶
type AstFile ¶
ast.File with token.FileSet
func NewAstFile ¶
NewAstFile parses the source code of a single Go source file and returns the corresponding ast.File node
func (*AstFile) ChangePackage ¶
Change package name
func (*AstFile) ContainsFunc ¶
ContainsFunc returns true if AST contains func fn
func (*AstFile) GetFuncDecl ¶
GetFuncDecl returns declaration of func named fn.
If there is no declaration, it returns nil.
func (AstFile) SaveTemp ¶
Save AST as source code to temp file.
SaveTemp returns filePath, temp file cleaner func , and error. Cleaner func is not always nil, so you may call it any time.
func (*AstFile) SwapSimpleFuncs ¶
Swap func name of fn1 and one of f2. * Funcs must not have arguments and return values.
If strict is true, fn1 and fn2 must be present. When either is not present, SwapSimpleFuncs returns error.
If strict is false, only present func is renamed, SwapSimpleFuncs returns no errors.