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

Function angularAppRoot

src/resolution/frameworks/angular-router.ts:678–698  ·  view source on GitHub ↗

* The app a routes file belongs to. An Angular workspace — the directory an * `angular.json` or an Nx `nx.json` sits in — is one app however its routes * are split: angular-spotify declares its screens across a dozen `libs/*` * packages, each with a `src/` of its own, and keyed by those every *

(filePath: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

676 * workspace, the conventional app root.
677 */
678function angularAppRoot(filePath: string, context: ResolutionContext): string {
679 const source = context.getNodesByKind('route');
680 let entry = workspaceRoots.get(context);
681 if (!entry || entry.source !== source) workspaceRoots.set(context, (entry = { source, memo: new Map() }));
682 const memo = entry.memo;
683 const slash = filePath.lastIndexOf('/');
684 const dir = slash < 0 ? '' : filePath.slice(0, slash);
685 let found = memo.get(dir);
686 if (found === undefined) {
687 found = null;
688 for (let d: string | null = dir; d !== null; d = d === '' ? null : d.includes('/') ? d.slice(0, d.lastIndexOf('/')) : '') {
689 const at = d === '' ? '' : `${d}/`;
690 if (context.fileExists(`${at}angular.json`) || context.fileExists(`${at}nx.json`)) {
691 found = at;
692 break;
693 }
694 }
695 memo.set(dir, found);
696 }
697 return found ?? appRootFor(filePath);
698}
699
700export type AngularRouteTable = RootedRouteTable;
701

Callers 3

angularRouteTableFunction · 0.85
angularAppCountFunction · 0.85
angular-router.tsFile · 0.85

Calls 5

appRootForFunction · 0.90
fileExistsMethod · 0.80
getNodesByKindMethod · 0.65
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected