Documentation ¶
Index ¶
- func Walk(f ast.Node, pms PatternMatchers)
- type BoolCondition
- type ChanDirCondition
- type ExprCondition
- type FilesMapCondition
- type ImportsMapCondition
- type Matcher
- type NodeCondition
- func ArrayType(elt, l NodeCondition) NodeCondition
- func AssignStmt(lhs, rhs NodesCondition) NodeCondition
- func BadDecl() NodeCondition
- func BadExpr() NodeCondition
- func BadStmt() NodeCondition
- func BasicLit(value string) NodeCondition
- func BinaryExpr(x, y NodeCondition) NodeCondition
- func BlockStmt(stmts NodesCondition) NodeCondition
- func BranchStmt(label NodeCondition) NodeCondition
- func CallExpr(fun NodeCondition, args NodesCondition) NodeCondition
- func CaseClause(list NodesCondition, body NodesCondition) NodeCondition
- func ChanType(k NodeCondition, v ChanDirCondition) NodeCondition
- func CommClause(comm NodeCondition, body NodesCondition) NodeCondition
- func CompositeLit(t NodeCondition, args NodesCondition) NodeCondition
- func DeclStmt(decl NodeCondition) NodeCondition
- func DeferStmt(call NodeCondition) NodeCondition
- func Ellipsis(elem NodeCondition) NodeCondition
- func EmptyStmt(implicit BoolCondition) NodeCondition
- func ExprStmt(x NodeCondition) NodeCondition
- func File(doc, name NodeCondition, decls NodesCondition, scope ScopeCondition, ...) NodeCondition
- func ForStmt(init, cond, post, body NodeCondition) NodeCondition
- func FuncDecl(doc, recv, name, t, body NodeCondition) NodeCondition
- func FuncLit(t, block NodeCondition) NodeCondition
- func FuncType(params, results NodeCondition) NodeCondition
- func GenDecl(doc NodeCondition, specs NodesCondition) NodeCondition
- func GoStmt(call NodeCondition) NodeCondition
- func Ident(name string) NodeCondition
- func IdentExpr(name string) NodeCondition
- func IfStmt(init, body, cond, els NodeCondition) NodeCondition
- func IgnoreNode() NodeCondition
- func ImportSpec(doc, name, importPath, comment NodeCondition) NodeCondition
- func IncDecStmt(x NodeCondition) NodeCondition
- func IndexExpr(x, index NodeCondition) NodeCondition
- func InterfaceType(methods NodeCondition, incomplete BoolCondition) NodeCondition
- func KeyValueExpr(k, v NodeCondition) NodeCondition
- func LabeledStmt(label, stmt NodeCondition) NodeCondition
- func MapType(k, v NodeCondition) NodeCondition
- func Package(scope ScopeCondition, name StringCondition, imports ImportsMapCondition, ...) NodeCondition
- func ParenExpr(x NodeCondition) NodeCondition
- func RangeStmt(k, v, x, body NodeCondition) NodeCondition
- func ReturnStmt(results NodesCondition) NodeCondition
- func SelectStmt(body NodeCondition) NodeCondition
- func SelectorExpr(x, sel NodeCondition) NodeCondition
- func SendStmt(channel, val NodeCondition) NodeCondition
- func SliceExpr(x, low, high, max NodeCondition) NodeCondition
- func Spec() NodeCondition
- func StarExpr(x NodeCondition) NodeCondition
- func StructType(fields NodeCondition, incomplete BoolCondition) NodeCondition
- func SwitchStmt(init, tag, body NodeCondition) NodeCondition
- func Type(t interface{}) NodeCondition
- func TypeAssertExpr(x, t NodeCondition) NodeCondition
- func TypeSpec(doc, name, t, comment NodeCondition) NodeCondition
- func TypeSwitchStmt(init, assign, body NodeCondition) NodeCondition
- func UnaryExpr(x NodeCondition) NodeCondition
- func ValueSpec(doc, t, comment NodeCondition, names NodesCondition, values NodesCondition) NodeCondition
- type NodeSelections
- func (s NodeSelections) BasicLit(key string) *ast.BasicLit
- func (s NodeSelections) BlockStmt(key string) *ast.BlockStmt
- func (s NodeSelections) CallExpr(key string) *ast.CallExpr
- func (s NodeSelections) ExprStmt(key string) *ast.ExprStmt
- func (s NodeSelections) Ident(key string) *ast.Ident
- func (s NodeSelections) IfStmt(key string) *ast.IfStmt
- func (s NodeSelections) ImportSpecs(key string) []*ast.ImportSpec
- func (s NodeSelections) Select(c NodeCondition, key string) NodeCondition
- func (s NodeSelections) Selects(c NodesCondition, key string) NodesCondition
- func (s NodeSelections) Stmt(key string) ast.Stmt
- type NodesCondition
- type PatternMatchers
- type ScopeCondition
- type StringCondition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Walk ¶
func Walk(f ast.Node, pms PatternMatchers)
Types ¶
type BoolCondition ¶
type ChanDirCondition ¶
type ExprCondition ¶
func Expr ¶
func Expr(x ExprCondition) ExprCondition
Expr check if the given ast.Expr matches the given condition.
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher helps to find ast portions of interest while walking through the tree.
func New ¶
func New(conditions []NodeCondition, processMatch func()) *Matcher
New returns a new instance of a Matcher.
type NodeCondition ¶
func ArrayType ¶
func ArrayType(elt, l NodeCondition) NodeCondition
ArrayType check if the given ast.ArrayType matches the given conditions.
func AssignStmt ¶
func AssignStmt(lhs, rhs NodesCondition) NodeCondition
AssignStmt check if the given ast.AssignStmt matches the given conditions.
func BadDecl ¶
func BadDecl() NodeCondition
BadDecl check if the given values type matches *ast.BadDecl.
func BasicLit ¶
func BasicLit(value string) NodeCondition
BasicLit check if the given ast.BasicLit matches the given conditions.
func BinaryExpr ¶
func BinaryExpr(x, y NodeCondition) NodeCondition
BinaryExpr check if the given ast.BinaryExpr matches the given conditions.
func BlockStmt ¶
func BlockStmt(stmts NodesCondition) NodeCondition
BlockStmt check if the given ast.BranchStmt matches the given conditions.
func BranchStmt ¶
func BranchStmt(label NodeCondition) NodeCondition
BranchStmt check if the given ast.BranchStmt matches the given conditions.
func CallExpr ¶
func CallExpr(fun NodeCondition, args NodesCondition) NodeCondition
CallExpr check if the given ast.CallExpr matches the given conditions.
func CaseClause ¶
func CaseClause(list NodesCondition, body NodesCondition) NodeCondition
CaseClause check if the given ast.CaseClause matches the given conditions.
func ChanType ¶
func ChanType(k NodeCondition, v ChanDirCondition) NodeCondition
ChanType check if the given ast.ChanType matches the given conditions.
func CommClause ¶
func CommClause(comm NodeCondition, body NodesCondition) NodeCondition
CommClause check if the given ast.CommClause matches the given conditions.
func CompositeLit ¶
func CompositeLit(t NodeCondition, args NodesCondition) NodeCondition
CompositeLit check if the given ast.ParenExpr matches the given conditions.
func DeclStmt ¶
func DeclStmt(decl NodeCondition) NodeCondition
DeclStmt check if the given ast.DeclStmt matches the given conditions.
func DeferStmt ¶
func DeferStmt(call NodeCondition) NodeCondition
DeferStmt check if the given ast.DeferStmt matches the given conditions.
func Ellipsis ¶
func Ellipsis(elem NodeCondition) NodeCondition
Ellipsis check if the given ast.Ellipsis matches the given conditions.
func EmptyStmt ¶
func EmptyStmt(implicit BoolCondition) NodeCondition
EmptyStmt check if the given ast.EmptyStmt matches the given conditions.
func ExprStmt ¶
func ExprStmt(x NodeCondition) NodeCondition
ExprStmt check if the given ast.ExprStmt matches the given conditions.
func File ¶
func File( doc, name NodeCondition, decls NodesCondition, scope ScopeCondition, imports, unresolved NodesCondition, comments NodesCondition) NodeCondition
File check if the given ast.File matches the given conditions.
func ForStmt ¶
func ForStmt(init, cond, post, body NodeCondition) NodeCondition
ForStmt check if the given ast.ForStmt matches the given conditions.
func FuncDecl ¶
func FuncDecl(doc, recv, name, t, body NodeCondition) NodeCondition
FuncDecl check if the given ast.FuncDecl matches the given conditions.
func FuncLit ¶
func FuncLit(t, block NodeCondition) NodeCondition
FuncLit check if the given ast.FuncLit matches the given conditions.
func FuncType ¶
func FuncType(params, results NodeCondition) NodeCondition
FuncType check if the given ast.FuncType matches the given conditions.
func GenDecl ¶
func GenDecl(doc NodeCondition, specs NodesCondition) NodeCondition
GenDecl check if the given ast.GenDecl matches the given conditions.
func GoStmt ¶
func GoStmt(call NodeCondition) NodeCondition
GoStmt check if the given ast.GoStmt matches the given conditions.
func Ident ¶
func Ident(name string) NodeCondition
Ident check if the given ast.Ident name matches the requested one.
func IdentExpr ¶
func IdentExpr(name string) NodeCondition
IdentExpr check if the given ast.IdentExpr name matches the requested one.
func IfStmt ¶
func IfStmt(init, body, cond, els NodeCondition) NodeCondition
IfStmt check if the given ast.IfStmt matches the given conditions.
func ImportSpec ¶
func ImportSpec(doc, name, importPath, comment NodeCondition) NodeCondition
ImportSpec check if the given ast.ImportSpec matches the given conditions.
func IncDecStmt ¶
func IncDecStmt(x NodeCondition) NodeCondition
IncDecStmt check if the given ast.IncDecStmt matches the given conditions.
func IndexExpr ¶
func IndexExpr(x, index NodeCondition) NodeCondition
IndexExpr check if the given ast.IndexExpr matches the given conditions.
func InterfaceType ¶
func InterfaceType(methods NodeCondition, incomplete BoolCondition) NodeCondition
InterfaceType check if the given ast.InterfaceType matches the given conditions.
func KeyValueExpr ¶
func KeyValueExpr(k, v NodeCondition) NodeCondition
KeyValueExpr check if the given ast.KeyValueExpr matches the given conditions.
func LabeledStmt ¶
func LabeledStmt(label, stmt NodeCondition) NodeCondition
LabeledStmt check if the given ast.LabeledStmt matches the given conditions.
func MapType ¶
func MapType(k, v NodeCondition) NodeCondition
MapType check if the given ast.MapType matches the given conditions.
func Package ¶
func Package( scope ScopeCondition, name StringCondition, imports ImportsMapCondition, files FilesMapCondition) NodeCondition
Package check if the given ast.Package matches the given conditions.
func ParenExpr ¶
func ParenExpr(x NodeCondition) NodeCondition
ParenExpr check if the given ast.ParenExpr matches the given conditions.
func RangeStmt ¶
func RangeStmt(k, v, x, body NodeCondition) NodeCondition
RangeStmt check if the given ast.RangeStmt matches the given conditions.
func ReturnStmt ¶
func ReturnStmt(results NodesCondition) NodeCondition
ReturnStmt check if the given ast.ReturnStmt matches the given conditions.
func SelectStmt ¶
func SelectStmt(body NodeCondition) NodeCondition
SelectStmt check if the given ast.SelectStmt matches the given conditions.
func SelectorExpr ¶
func SelectorExpr(x, sel NodeCondition) NodeCondition
SelectorExpr check if the given ast.SelectorExpr matches the given conditions.
func SendStmt ¶
func SendStmt(channel, val NodeCondition) NodeCondition
SendStmt check if the given ast.SendStmt matches the given conditions.
func SliceExpr ¶
func SliceExpr(x, low, high, max NodeCondition) NodeCondition
SliceExpr check if the given ast.SliceExpr matches the given conditions.
func Spec ¶
func Spec() NodeCondition
Spec check if the given values type matches the requested one.
func StarExpr ¶
func StarExpr(x NodeCondition) NodeCondition
StarExpr check if the given ast.TypeAssertExpr matches the given conditions.
func StructType ¶
func StructType(fields NodeCondition, incomplete BoolCondition) NodeCondition
StructType check if the given ast.StructType matches the given conditions.
func SwitchStmt ¶
func SwitchStmt(init, tag, body NodeCondition) NodeCondition
SwitchStmt check if the given ast.SwitchStmt matches the given conditions.
func Type ¶
func Type(t interface{}) NodeCondition
Type check if the given values type matches the requested one.
func TypeAssertExpr ¶
func TypeAssertExpr(x, t NodeCondition) NodeCondition
TypeAssertExpr check if the given ast.TypeAssertExpr matches the given conditions.
func TypeSpec ¶
func TypeSpec(doc, name, t, comment NodeCondition) NodeCondition
TypeSpec check if the given ast.TypeSpec matches the given conditions.
func TypeSwitchStmt ¶
func TypeSwitchStmt(init, assign, body NodeCondition) NodeCondition
TypeSwitchStmt check if the given ast.SwitchStmt matches the given conditions.
func UnaryExpr ¶
func UnaryExpr(x NodeCondition) NodeCondition
UnaryExpr check if the given ast.UnaryExpr matches the given conditions.
func ValueSpec ¶
func ValueSpec(doc, t, comment NodeCondition, names NodesCondition, values NodesCondition) NodeCondition
ValueSpec check if the given ast.ValueSpec matches the given conditions.
type NodeSelections ¶
NodeSelections contain nodes that were selected during matching. They are stored as Pointers on the existing ast.Node Pointers so they can be used to manipulate the tree in memory.
func (NodeSelections) BasicLit ¶
func (s NodeSelections) BasicLit(key string) *ast.BasicLit
BasicLit returns a pointer to the ast.Basic that was selected using the given key.
func (NodeSelections) BlockStmt ¶
func (s NodeSelections) BlockStmt(key string) *ast.BlockStmt
BlockStmt returns a pointer to the ast.BlockStmt that was selected using the given key.
func (NodeSelections) CallExpr ¶
func (s NodeSelections) CallExpr(key string) *ast.CallExpr
CallExpr returns a pointer to the ast.CallExpr that was selected using the given key.
func (NodeSelections) ExprStmt ¶
func (s NodeSelections) ExprStmt(key string) *ast.ExprStmt
ExprStmt returns a pointer to the ast.ExprStmt that was selected using the given key.
func (NodeSelections) Ident ¶
func (s NodeSelections) Ident(key string) *ast.Ident
Ident returns a pointer to the ast.Ident that was selected using the given key.
func (NodeSelections) IfStmt ¶
func (s NodeSelections) IfStmt(key string) *ast.IfStmt
IfStmt returns a pointer to the ast.IfStmt that was selected using the given key.
func (NodeSelections) ImportSpecs ¶
func (s NodeSelections) ImportSpecs(key string) []*ast.ImportSpec
ExprStmt returns a pointer to the ast.ExprStmt that was selected using the given key.
func (NodeSelections) Select ¶
func (s NodeSelections) Select(c NodeCondition, key string) NodeCondition
Select will select the visited node for the given key if the given condition matches.
func (NodeSelections) Selects ¶
func (s NodeSelections) Selects(c NodesCondition, key string) NodesCondition
Select will select the visited nodes for the given key if the given condition matches.
type NodesCondition ¶
func Exprs ¶
func Exprs(x []NodeCondition) NodesCondition
Exprs check if the given []ast.Node matches the given conditions in sequence.
func First ¶
func First(c NodeCondition) NodesCondition
func IgnoreNodes ¶
func IgnoreNodes() NodesCondition
func Last ¶
func Last(c NodeCondition) NodesCondition
type PatternMatchers ¶
type PatternMatchers []*Matcher
PatternMatchers holds multiple matchers.
func (PatternMatchers) Match ¶
func (m PatternMatchers) Match(n ast.Node)
Walk matches all matchers against the given node.
type ScopeCondition ¶
func IgnoreScope ¶
func IgnoreScope() ScopeCondition