Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Analyzer = &analysis.Analyzer{ Name: "match", Doc: "todo", Requires: []*analysis.Analyzer{ inspect.Analyzer, }, Run: func(p *analysis.Pass) (any, error) { inspect := p.ResultOf[inspect.Analyzer].(*inspector.Inspector) patch, err := gopatch.Parse(bytes.NewBuffer([]byte(` -import "errors" -errors.New(fmt.Sprintf(...)) +fmt.Errorf(...) `))) if err != nil { return nil, err } before := patch.Patches[0].Diff.Before() after := patch.Patches[0].Diff.After() fmt.Printf("Before: %s\n", before.Root.String()) fmt.Printf("After: %s\n", after.Root.String()) inspect.Preorder([]ast.Node{ (*ast.CallExpr)(nil), }, func(n ast.Node) { _, edits, ok := code.MatchAndEdit(p, before, after, n) if ok { fmt.Printf("Matched! %s\n", edits[0].NewText) } }) return nil, nil }, }
Functions ¶
This section is empty.
Types ¶
type ArgumentPattern ¶
type ArgumentPattern struct { }
type CallPattern ¶
func (*CallPattern) Nodes ¶
func (p *CallPattern) Nodes() []ast.Node
type NamedPattern ¶
func (*NamedPattern) Nodes ¶
func (p *NamedPattern) Nodes() []ast.Node
Click to show internal directories.
Click to hide internal directories.