( fn: FunctionNode, module: SourceModule )
| 3574 | |
| 3575 | // e.g. `f(A)`, `(t => t)(A)` or `new C(A)` for C's constructor; undefined if `f` escapes |
| 3576 | callsOf( |
| 3577 | fn: FunctionNode, |
| 3578 | module: SourceModule |
| 3579 | ): (CallExpression | NewExpression)[] | undefined { |
| 3580 | const cls = |
| 3581 | ( |
| 3582 | fn.parent?.type === "MethodDefinition" && |
| 3583 | fn.parent.kind === "constructor" |
| 3584 | ) ? |
| 3585 | fn.parent.parent!.parent! |
| 3586 | : undefined |
| 3587 | const binding = bindingOfFunction(cls ?? fn, module) |
| 3588 | if (cls && (!binding || constructsReflectively(module))) return |
| 3589 | if (binding && (binding.exportNames.length || binding.writes.length)) return |
| 3590 | const result: (CallExpression | NewExpression)[] = [] |
| 3591 | for (const id of binding ? binding.references.map(r => r.id) : [fn]) { |
| 3592 | if (isNamed(id, module)) continue |
| 3593 | const [operand, operator] = operatorOf(id) |
| 3594 | if ( |
| 3595 | (operator?.type !== "CallExpression" && |
| 3596 | operator?.type !== "NewExpression") || |
| 3597 | operator.callee !== operand |
| 3598 | ) |
| 3599 | return |
| 3600 | result.push(operator) |
| 3601 | } |
| 3602 | return result |
| 3603 | } |
| 3604 | |
| 3605 | private patternKindOf( |
| 3606 | node: Node, |
no test coverage detected