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

Function angularAppRoot

src/resolution/frameworks/angular-router.ts:676–696  ·  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

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

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