Skip to content

Commit

Permalink
findallInAST bug
Browse files Browse the repository at this point in the history
  • Loading branch information
emad-elsaid committed Jan 14, 2023
1 parent db4d1a2 commit bb1668e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func FindInAST[t ast.Node](n ast.Node) (found t, ok bool) {
// Extract all nodes of a specific type from the AST
func FindAllInAST[t ast.Node](n ast.Node) (a []t) {
ast.Walk(n, func(n ast.Node, entering bool) (ast.WalkStatus, error) {
if !entering {
return ast.WalkContinue, nil
}

if casted, ok := n.(t); ok {
a = append(a, casted)
}
Expand Down

0 comments on commit bb1668e

Please sign in to comment.