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

Function declaringFile

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

The file declaring `name` for code in `fromFile`: its import, else the file itself.

(name: string, fromFile: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

592
593/** The file declaring `name` for code in `fromFile`: its import, else the file itself. */
594function declaringFile(name: string, fromFile: string, context: ResolutionContext): string | null {
595 const content = context.readFile(fromFile);
596 if (!content) return null;
597 const imports = /\bimport\s*\{([^}]*)\}\s*from\s*(['"])([^'"]+)\2/g;
598 let m: RegExpExecArray | null;
599 while ((m = imports.exec(content)) !== null) {
600 const names = m[1]!.split(',').map((s) => s.trim().split(/\s+as\s+/).pop()!.trim());
601 if (names.includes(name)) return resolveImportPath(m[3]!, fromFile, 'typescript', context);
602 }
603 return fromFile;
604}
605
606// =============================================================================
607// Route table

Callers 2

routeComponentFunction · 0.85
constantTextFunction · 0.85

Calls 4

resolveImportPathFunction · 0.90
mapMethod · 0.80
readFileMethod · 0.65
execMethod · 0.65

Tested by

no test coverage detected