MCPcopy Index your code
hub / github.com/coder/coder / argList

Function argList

coderd/database/gentest/modelqueries_test.go:113–147  ·  view source on GitHub ↗
(t *testing.T, args []ast.Expr)

Source from the content-addressed store, hash-verified

111}
112
113func argList(t *testing.T, args []ast.Expr) []string {
114 defer func() {
115 if r := recover(); r != nil {
116 t.Errorf("Recovered in f reading arg names: %s", r)
117 }
118 }()
119
120 var argNames []string
121 for _, arg := range args {
122 argname := "unknown"
123 // This is "&i.Arg" style stuff
124 if unary, ok := arg.(*ast.UnaryExpr); ok {
125 argname = unary.X.(*ast.SelectorExpr).Sel.Name
126 }
127 if ident, ok := arg.(*ast.Ident); ok {
128 argname = ident.Name
129 }
130 if sel, ok := arg.(*ast.SelectorExpr); ok {
131 argname = sel.Sel.Name
132 }
133 if call, ok := arg.(*ast.CallExpr); ok {
134 // Eh, this is pg.Array style stuff. Do a best effort.
135 argname = fmt.Sprintf("call(%d)", len(call.Args))
136 if fnCall, ok := call.Fun.(*ast.SelectorExpr); ok {
137 argname = fmt.Sprintf("%s(%d)", fnCall.Sel.Name, len(call.Args))
138 }
139 }
140
141 if argname == "unknown" {
142 t.Errorf("Unknown arg, cannot parse: %T", arg)
143 }
144 argNames = append(argNames, argname)
145 }
146 return argNames
147}
148
149func pullQueryArgs(fn *ast.FuncDecl) []ast.Expr {
150 for _, exp := range fn.Body.List {

Callers 1

compareArgsFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected