MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / callSiteInTree

Function callSiteInTree

src/graph/branch-guards.ts:531–561  ·  view source on GitHub ↗
(root: SyntaxNode, source: string, line: number, column: number | null, want?: string)

Source from the content-addressed store, hash-verified

529}
530
531export 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
563const BODY_REPLY = /^(?:res|response|reply|rep|ctx|c|context)\.(?:json|jsonp|send|render|sendFile|download|end|text|html|body)$/;
564const STATEMENT_BLOCKS: ReadonlySet<string> = new Set(['statement_block', 'program', 'block', 'class_body', 'module']);

Callers 3

callArgumentsInTreeFunction · 0.85
callSitesForFileFunction · 0.85
callSiteInSourceFunction · 0.85

Calls 9

argumentsOfFunction · 0.85
calleeChainTextFunction · 0.85
abbreviateArgumentFunction · 0.85
statusPropertyInFunction · 0.85
statusSetBeforeFunction · 0.85
enclosingCallTextFunction · 0.85
pushMethod · 0.80
callAtFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected