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

Function resolve

src/resolution/frameworks/tanstack-router.ts:440–475  ·  view source on GitHub ↗
(ref: UnresolvedRef, context: ResolutionContext)

Source from the content-addressed store, hash-verified

438 },
439
440 resolve(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null {
441 if (ref.referenceKind !== 'calls') return null;
442 const verb = tanstackNavVerb(ref.referenceName);
443 if (!verb) return null;
444 if (!ROUTE_LANGUAGES.includes(ref.language)) return null;
445 const routes = routesForFile(tanstackTable(context), ref.filePath);
446 if (!routes || routes.exact.size === 0) return null;
447 const lines = context.getFileLines?.(ref.filePath) ?? context.readFile(ref.filePath)?.split(/\r?\n/) ?? null;
448 if (!lines) return null;
449
450 const arg = firstArgumentText(lines, ref.line, ref.column, verb);
451 if (arg === null) return null;
452 let href = tanstackDestination(arg);
453 if (!href) {
454 const enclosing = context.getNodeById?.(ref.fromNodeId);
455 const start = enclosing && enclosing.filePath === ref.filePath ? enclosing.startLine : Math.max(1, ref.line - 40);
456 href = readHrefViaLocal(lines, ref.line, ref.column, verb, start);
457 }
458 if (!href) return null;
459 // Every arm of a conditional destination is somewhere this call goes; the
460 // first is this reference's resolution and the rest ride as `alsoTargets`.
461 const targets = destinationsForHref(href, routes);
462 const target = targets[0];
463 if (!target) return null;
464 return {
465 original: ref,
466 targetNodeId: target.node.id,
467 ...(targets.length > 1
468 ? { alsoTargets: targets.slice(1).map((t) => ({ targetNodeId: t.node.id, metadata: { href: t.href.display, navMethod: verb } })) }
469 : {}),
470 confidence: 0.95,
471 resolvedBy: 'framework',
472 edgeKind: 'navigates',
473 metadata: { href: target.href.display, navMethod: verb },
474 };
475 },
476};

Callers

nothing calls this directly

Calls 11

routesForFileFunction · 0.90
firstArgumentTextFunction · 0.90
readHrefViaLocalFunction · 0.90
destinationsForHrefFunction · 0.90
tanstackNavVerbFunction · 0.85
tanstackTableFunction · 0.85
tanstackDestinationFunction · 0.85
getFileLinesMethod · 0.80
mapMethod · 0.80
readFileMethod · 0.65
getNodeByIdMethod · 0.65

Tested by

no test coverage detected