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

Function extract

src/resolution/frameworks/angular-router.ts:1010–1046  ·  view source on GitHub ↗
(filePath: string, content: string)

Source from the content-addressed store, hash-verified

1008 },
1009
1010 extract(filePath: string, content: string): FrameworkExtractionResult {
1011 if (!/\.[cm]?ts$/.test(filePath) || filePath.endsWith('.d.ts')) return { nodes: [], references: [] };
1012 const { routes } = parseAngularRoutes(content);
1013 if (routes.length === 0) return { nodes: [], references: [] };
1014 const now = Date.now();
1015 const nodes: Node[] = [];
1016 const references: UnresolvedRef[] = [];
1017 for (const route of routes) {
1018 const node: Node = {
1019 id: routeId(filePath, route.line, route.path),
1020 kind: 'route',
1021 name: route.path,
1022 qualifiedName: `${filePath}::route:${route.path}`,
1023 filePath,
1024 startLine: route.line,
1025 endLine: route.line,
1026 startColumn: 0,
1027 endColumn: 0,
1028 language: 'typescript',
1029 updatedAt: now,
1030 };
1031 nodes.push(node);
1032 const ref = (component: AngularComponentRef, layout: boolean): UnresolvedRef => ({
1033 fromNodeId: node.id,
1034 referenceName: `${layout ? 'layout:' : ''}${component.spec === null ? component.name : `import:${component.spec}#${component.name ?? 'default'}`}`,
1035 referenceKind: 'references',
1036 line: route.line,
1037 column: 0,
1038 filePath,
1039 language: 'typescript',
1040 });
1041 if (route.component) references.push(ref(route.component, false));
1042 // The layouts around it: their links and buttons are on this screen too.
1043 for (const layout of route.layouts) references.push(ref(layout, true));
1044 }
1045 return { nodes, references };
1046 },
1047
1048 /**
1049 * Put each routes file's routes under the path that lazy-loads it, and read

Callers

nothing calls this directly

Calls 4

parseAngularRoutesFunction · 0.85
pushMethod · 0.80
routeIdFunction · 0.70
refFunction · 0.70

Tested by

no test coverage detected