MCPcopy Create free account
hub / github.com/arktypeio/arktype / callsOf

Method callsOf

ark/aot/graph.ts:3576–3603  ·  view source on GitHub ↗
(
		fn: FunctionNode,
		module: SourceModule
	)

Source from the content-addressed store, hash-verified

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,

Callers 5

paramKindOfMethod · 0.95
passedMemberKindOfMethod · 0.95
passedMemberKindInMethod · 0.95
returnReachesUnseenMethod · 0.95
mayWriteFromMethod · 0.95

Calls 6

operatorOfFunction · 0.90
bindingOfFunctionFunction · 0.85
constructsReflectivelyFunction · 0.85
isNamedFunction · 0.85
mapMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected