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

Function directCallsOfFunction

ark/aot/usage.ts:2352–2409  ·  view source on GitHub ↗
(
	fn: Node,
	module: SourceModule,
	ctx: ThisReadsContext
)

Source from the content-addressed store, hash-verified

2350}
2351
2352const directCallsOfFunction = (
2353 fn: Node,
2354 module: SourceModule,
2355 ctx: ThisReadsContext
2356): CallSite[] | undefined => {
2357 if (
2358 fn.type === "FunctionExpression" &&
2359 fn.id &&
2360 module.scopes.bindingsById.get(fn.id)?.references.length
2361 )
2362 return
2363 const [op, parent] = operatorOf(fn)
2364 if (parent?.type === "CallExpression" && parent.callee === op)
2365 return [{ call: parent, module }]
2366 const calls: CallSite[] = []
2367 const seenBindings = new Set<Binding>()
2368 const seenExports = new Set<string>()
2369 if (
2370 parent?.type === "ExportDefaultDeclaration" &&
2371 parent.declaration === op
2372 ) {
2373 return (
2374 collectExportCalls(
2375 module,
2376 "default",
2377 ctx,
2378 calls,
2379 seenBindings,
2380 seenExports
2381 )
2382 ) ?
2383 calls
2384 : undefined
2385 }
2386 const binding =
2387 fn.type === "FunctionDeclaration" ?
2388 fn.id && module.scopes.bindingsById.get(fn.id)
2389 : (
2390 parent?.type === "VariableDeclarator" &&
2391 parent.init === op &&
2392 parent.id.type === "Identifier"
2393 ) ?
2394 module.scopes.bindingsById.get(parent.id)
2395 : undefined
2396 if (!binding) return
2397 return (
2398 collectBindingCalls(
2399 binding,
2400 module,
2401 ctx,
2402 calls,
2403 seenBindings,
2404 seenExports
2405 )
2406 ) ?
2407 calls
2408 : undefined
2409}

Callers 1

isForwardingParamFunction · 0.85

Calls 4

operatorOfFunction · 0.90
collectExportCallsFunction · 0.85
collectBindingCallsFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected