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

Function findCallExpressionInRange

ark/attest/cli/trace.ts:467–491  ·  view source on GitHub ↗
(
	file: ts.SourceFile,
	start: number,
	end: number
)

Source from the content-addressed store, hash-verified

465}
466
467const findCallExpressionInRange = (
468 file: ts.SourceFile,
469 start: number,
470 end: number
471): ts.CallExpression | undefined => {
472 const boundingCall = nearestBoundingCallExpression(file, start)
473 if (boundingCall && boundingCall.pos >= start && boundingCall.end <= end)
474 return boundingCall
475
476 const allNodes = getDescendants(file)
477 const nodesInRange = allNodes.filter(
478 node => node.pos >= start && node.end <= end
479 )
480
481 const callExpressions = nodesInRange.filter(node =>
482 syntax.isCallExpression(node)
483 ) as ts.CallExpression[]
484
485 if (callExpressions.length === 0) return undefined
486
487 const methodCalls = callExpressions.filter(call =>
488 syntax.isPropertyAccessExpression(call.expression)
489 )
490 return methodCalls.length > 0 ? methodCalls[0] : callExpressions[0]
491}
492
493const extractFunctionName = (callExpr: ts.CallExpression): string => {
494 if (syntax.isPropertyAccessExpression(callExpr.expression))

Callers 1

processDurationEntryFunction · 0.85

Calls 3

getDescendantsFunction · 0.90
filterMethod · 0.80

Tested by

no test coverage detected