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

Function routeReferences

src/resolution/frameworks/react.ts:1952–1961  ·  view source on GitHub ↗

The references that bind a route: what it renders, and the layouts around it.

(route: RouteDeclaration, fromNodeId: string, filePath: string, line: number)

Source from the content-addressed store, hash-verified

1950
1951/** The references that bind a route: what it renders, and the layouts around it. */
1952function routeReferences(route: RouteDeclaration, fromNodeId: string, filePath: string, line: number): UnresolvedRef[] {
1953 const language = filePath.endsWith('.tsx') ? 'tsx' : 'jsx';
1954 const ref = (referenceName: string): UnresolvedRef =>
1955 ({ fromNodeId, referenceName, referenceKind: 'references', line, column: 0, filePath, language });
1956 const refs: UnresolvedRef[] = [];
1957 const target = route.component ?? route.lazy;
1958 if (target) refs.push(ref(target));
1959 for (const layout of route.layouts) refs.push(ref(LAYOUT_PREFIX + layout));
1960 return refs;
1961}
1962
1963/**
1964 * Routes written in a table that another file hands to the router.

Callers 2

extractFunction · 0.85
tableRoutesFunction · 0.85

Calls 2

pushMethod · 0.80
refFunction · 0.70

Tested by

no test coverage detected