extractArgumentsType returns the name of the type of each input argument.
(f *ast.FuncDecl)
| 210 | |
| 211 | // extractArgumentsType returns the name of the type of each input argument. |
| 212 | func extractArgumentsType(f *ast.FuncDecl) ([]string, bool) { |
| 213 | var fields []*ast.Field |
| 214 | if f.Recv != nil { |
| 215 | if len(f.Recv.List) != 1 { |
| 216 | panic("Expect only one receiver; please fix panicparse's code") |
| 217 | } |
| 218 | // If it is an object receiver (vs a pointer receiver), its address is not |
| 219 | // printed in the stack trace so it needs to be ignored. |
| 220 | if _, ok := f.Recv.List[0].Type.(*ast.StarExpr); ok { |
| 221 | fields = append(fields, f.Recv.List[0]) |
| 222 | } |
| 223 | } |
| 224 | var types []string |
| 225 | ellipsis := false |
| 226 | for _, arg := range append(fields, f.Type.Params.List...) { |
| 227 | // Assert that ellipsis is only set on the last item of fields? |
| 228 | var t string |
| 229 | t, ellipsis = fieldToType(arg) |
| 230 | mult := len(arg.Names) |
| 231 | if mult == 0 { |
| 232 | mult = 1 |
| 233 | } |
| 234 | for i := 0; i < mult; i++ { |
| 235 | types = append(types, t) |
| 236 | } |
| 237 | } |
| 238 | return types, ellipsis |
| 239 | } |
| 240 | |
| 241 | // augmentCall walks the function and populate call accordingly. |
| 242 | func augmentCall(call *Call, f *ast.FuncDecl) { |
no test coverage detected
searching dependent graphs…