Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAncestor ¶
GetAncestor returns the closest ancestor of the given type.
func Walk ¶
Walk walks the AST starting with root.
This function combines the behaviour of ast.Walk, astutil.Inspect, and astutil.Apply.
- From ast.Walk we have the ability to swap out the visitor for each subtree of nodes - From astutil.Inspect we track all the parent nodes walked through to get to the current node - From astutil.Apply we have the ability to insert, delete or replace nodes via the Cursor
Types ¶
type Cursor ¶
func (*Cursor) DocComment ¶
DocComment returns the doc comment associated with the given node. It walks through the parent nodes until it finds a node with a Comment field or fields, and stops when it comes across a node which represents a block where a previous comment would no longer be valid (such as a FuncType, StructType, InterfaceType or BlockStmt).