(root: SyntaxNode, source: string, line: number, column: number | null, want?: string)
| 529 | } |
| 530 | |
| 531 | export function callSiteInTree(root: SyntaxNode, source: string, line: number, column: number | null, want?: string): CallSiteText | null { |
| 532 | const call = callAt(root, source, line, column, want); |
| 533 | if (!call) return null; |
| 534 | const container = argumentsOf(call); |
| 535 | if (!container) return null; |
| 536 | const callee = calleeChainText(call, container); |
| 537 | if (container.type === 'lambda_literal') return { callee, args: '{ … }', argList: ['{ … }'] }; |
| 538 | const parts: string[] = []; |
| 539 | let status: number | null = null; |
| 540 | for (let i = 0; i < container.namedChildCount; i++) { |
| 541 | const c = container.namedChild(i); |
| 542 | if (!c || c.type === 'comment') continue; |
| 543 | parts.push(abbreviateArgument(c, source)); |
| 544 | if (status === null && c.type !== 'comment') status = statusPropertyIn(c); |
| 545 | } |
| 546 | const text = parts.join(', '); |
| 547 | if (status === null) status = statusSetBefore(call, callee); |
| 548 | const span = { |
| 549 | start: { line: call.startPosition.row + 1, column: call.startPosition.column }, |
| 550 | end: { line: call.endPosition.row + 1, column: call.endPosition.column }, |
| 551 | }; |
| 552 | const within = enclosingCallText(call); |
| 553 | return { |
| 554 | callee, |
| 555 | args: text.length > MAX_ARGS_TEXT ? `${text.slice(0, MAX_ARGS_TEXT - 1)}…` : text, |
| 556 | argList: parts, |
| 557 | span, |
| 558 | ...(within ? { within } : {}), |
| 559 | ...(status !== null ? { status } : {}), |
| 560 | }; |
| 561 | } |
| 562 | |
| 563 | const BODY_REPLY = /^(?:res|response|reply|rep|ctx|c|context)\.(?:json|jsonp|send|render|sendFile|download|end|text|html|body)$/; |
| 564 | const STATEMENT_BLOCKS: ReadonlySet<string> = new Set(['statement_block', 'program', 'block', 'class_body', 'module']); |
no test coverage detected