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

Function hopAt

src/ui-server/api/steps.ts:464–483  ·  view source on GitHub ↗
(caller: Node, at: { line?: number; column?: number }, callee?: string)

Source from the content-addressed store, hash-verified

462 const callAt = (caller: Node, site: { line?: number; column?: number; callee?: string }) => calls.callSite(caller, site);
463 /** A hop's position with its call's span and enclosing call, read from the tree; the bare position when unreadable. */
464 const hopAt = async (caller: Node, at: { line?: number; column?: number }, callee?: string): Promise<HopSite> => {
465 const line = at.line ?? caller.startLine;
466 const column = at.column ?? 0;
467 const read = at.line ? await callAt(caller, { ...at, ...(callee ? { callee } : {}) }) : null;
468 // The read must be THIS call. An inline handler's edges carry the ROUTE's
469 // line (`router.post('/users/login', async (req, res) => {`), where the
470 // only call is the registration itself — and taking its span would make
471 // every call in the handler read as written inside it, and so as running
472 // first. A miss is a bare position: no span to nest by, no `within`.
473 const last = (n: string) => n.replace(/\([^()]*\)/g, '').split(/[.:]/).pop() ?? n;
474 const usable = read !== null && (!callee || last(read.callee) === last(callee));
475 if (!usable) return { file: caller.filePath, line, column, end: { line, column }, within: null };
476 return {
477 file: caller.filePath,
478 line: read.span?.start.line ?? line,
479 column: read.span?.start.column ?? column,
480 end: read.span?.end ?? { line, column },
481 within: read.within ?? null,
482 };
483 };
484 const pointHop = (caller: Node, at: { line?: number; column?: number }): HopSite => {
485 const line = at.line ?? caller.startLine;
486 const column = at.column ?? 0;

Callers 1

buildStepsFunction · 0.85

Calls 2

lastFunction · 0.85
callAtFunction · 0.70

Tested by

no test coverage detected