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

Function extract

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

Source from the content-addressed store, hash-verified

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