File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ func PrintJSON(node syntax.Node) {
1717}
1818
1919func PrintCode (node syntax.Node ) {
20+
21+ if node == nil {
22+ return
23+ }
2024 printer := syntax .NewPrinter (syntax .Minify (true ))
2125 err := printer .Print (os .Stdout , node )
2226 if err != nil {
Original file line number Diff line number Diff line change 11package shutils
22
33import (
4+ "fmt"
5+
46 "github.com/samber/lo"
57 "mvdan.cc/sh/v3/syntax"
68)
@@ -17,7 +19,13 @@ func ExtractFunctions(node syntax.Node) []*syntax.FuncDecl {
1719}
1820
1921func Func (node syntax.Node , name string ) * syntax.FuncDecl {
20- return lo .Filter (ExtractFunctions (node ), func (d * syntax.FuncDecl , n int ) bool {
22+ // return lo.Filter(ExtractFunctions(node), func(d *syntax.FuncDecl, n int) bool {
23+ // return d.Name.Value == name
24+ // })[0]
25+
26+ f , _ := lo .Find (ExtractFunctions (node ), func (d * syntax.FuncDecl ) bool {
2127 return d .Name .Value == name
22- })[0 ]
28+ })
29+ fmt .Println (f )
30+ return f
2331}
You can’t perform that action at this time.
0 commit comments