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

Function tableNamed

src/resolution/frameworks/react.ts:2080–2092  ·  view source on GitHub ↗

* The literals a table name stands for in `file`: declared there, or * imported. A value that holds a call's result — Medusa's `const routes = * getRouteMap({ … })` — stands for the tables the function returns.

(named: TableName, file: string, context: ResolutionContext, depth = 0)

Source from the content-addressed store, hash-verified

2078 * getRouteMap({ … })` — stands for the tables the function returns.
2079 */
2080function tableNamed(named: TableName, file: string, context: ResolutionContext, depth = 0): TableLiteral[] {
2081 const source = context.readFile(file);
2082 if (!source) return [];
2083 const safe = stripCommentsForRegex(source, 'typescript');
2084 const local = declaredTable(safe, named.name, named.call, visibleAt(named.at, safe, file, context));
2085 if (local.length > 0) return tablesAt(local, file, context, depth);
2086 const language = scriptLanguage(file);
2087 const mapping = context.getImportMappings(file, language).find((m) => m.localName === named.name);
2088 if (!mapping || mapping.isNamespace || depth > 3) return [];
2089 const target = resolveImportPath(mapping.source, file, language, context);
2090 if (!target) return [];
2091 return exportedTable(target, mapping.isDefault ? 'default' : mapping.exportedName, named.call, context, depth + 1);
2092}
2093
2094/** The literals `sites` in `file` stand for: each literal written there, and the tables each function named returns. */
2095function tablesAt(sites: TableSite[], file: string, context: ResolutionContext, depth: number): TableLiteral[] {

Callers 2

tableRoutesFunction · 0.85
tablesAtFunction · 0.85

Calls 9

stripCommentsForRegexFunction · 0.90
resolveImportPathFunction · 0.90
declaredTableFunction · 0.85
visibleAtFunction · 0.85
tablesAtFunction · 0.85
scriptLanguageFunction · 0.85
exportedTableFunction · 0.85
getImportMappingsMethod · 0.80
readFileMethod · 0.65

Tested by

no test coverage detected