github.com/Secbyte/godog@v0.7.14-0.20200116175429-d8f0aeeb70cf/ast.go (about) 1 package godog 2 3 import "go/ast" 4 5 func astContexts(f *ast.File) []string { 6 var contexts []string 7 for _, d := range f.Decls { 8 switch fun := d.(type) { 9 case *ast.FuncDecl: 10 for _, param := range fun.Type.Params.List { 11 switch expr := param.Type.(type) { 12 case *ast.StarExpr: 13 switch x := expr.X.(type) { 14 case *ast.Ident: 15 if x.Name == "Suite" { 16 contexts = append(contexts, fun.Name.Name) 17 } 18 case *ast.SelectorExpr: 19 switch t := x.X.(type) { 20 case *ast.Ident: 21 if t.Name == "godog" && x.Sel.Name == "Suite" { 22 contexts = append(contexts, fun.Name.Name) 23 } 24 } 25 } 26 } 27 } 28 } 29 } 30 return contexts 31 }