| 352 | } |
| 353 | |
| 354 | function findHOCCallPathsAbove(path) { |
| 355 | const calls = []; |
| 356 | while (true) { |
| 357 | if (!path) { |
| 358 | return calls; |
| 359 | } |
| 360 | const parentPath = path.parentPath; |
| 361 | if (!parentPath) { |
| 362 | return calls; |
| 363 | } |
| 364 | if ( |
| 365 | // hoc(_c = function() { }) |
| 366 | parentPath.node.type === 'AssignmentExpression' && |
| 367 | path.node === parentPath.node.right |
| 368 | ) { |
| 369 | // Ignore registrations. |
| 370 | path = parentPath; |
| 371 | continue; |
| 372 | } |
| 373 | if ( |
| 374 | // hoc1(hoc2(...)) |
| 375 | parentPath.node.type === 'CallExpression' && |
| 376 | path.node !== parentPath.node.callee |
| 377 | ) { |
| 378 | calls.push(parentPath); |
| 379 | path = parentPath; |
| 380 | continue; |
| 381 | } |
| 382 | return calls; // Stop at other types. |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | const seenForRegistration = new WeakSet(); |
| 387 | const seenForSignature = new WeakSet(); |