(text)
| 335 | } |
| 336 | |
| 337 | function parseFnType(text) { |
| 338 | var args = [], pos = 3; |
| 339 | |
| 340 | function skipMatching(upto) { |
| 341 | var depth = 0, start = pos; |
| 342 | for (;;) { |
| 343 | var next = text.charAt(pos); |
| 344 | if (upto.test(next) && !depth) return text.slice(start, pos); |
| 345 | if (/[{\[\(]/.test(next)) ++depth; |
| 346 | else if (/[}\]\)]/.test(next)) --depth; |
| 347 | ++pos; |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | // Parse arguments |
| 352 | if (text.charAt(pos) != ")") for (;;) { |
| 353 | var name = text.slice(pos).match(/^([^, \(\[\{]+): /); |
| 354 | if (name) { |
| 355 | pos += name[0].length; |
| 356 | name = name[1]; |
| 357 | } |
| 358 | args.push({name: name, type: skipMatching(/[\),]/)}); |
| 359 | if (text.charAt(pos) == ")") break; |
| 360 | pos += 2; |
| 361 | } |
| 362 | |
| 363 | var rettype = text.slice(pos).match(/^\) -> (.*)$/); |
| 364 | |
| 365 | return {args: args, rettype: rettype && rettype[1]}; |
| 366 | } |
| 367 | |
| 368 | // Moving to the definition of something |
| 369 |
no test coverage detected