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

Function declaringFile

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

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

Callers 2

routeComponentFunction · 0.85
constantTextFunction · 0.85

Calls 4

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

Tested by

no test coverage detected