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

Function includesOf

src/resolution/pascal-scope.ts:2446–2465  ·  view source on GitHub ↗

The include files a Pascal file pulls in (`{$I name.inc}`, `{$INCLUDE name}`), each the one of that name nearest it.

(filePath: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

2444
2445/** The include files a Pascal file pulls in (`{$I name.inc}`, `{$INCLUDE name}`), each the one of that name nearest it. */
2446function includesOf(filePath: string, context: ResolutionContext): string[] {
2447 const m = memos(context);
2448 let includes = m.includes.get(filePath);
2449 if (includes) return includes;
2450 includes = [];
2451 if (PASCAL_SOURCE.test(filePath)) {
2452 for (const text of fileLines(filePath, context)) {
2453 if (!text.includes('{$') || !/\{\$i(?:nclude)?\s/i.test(text)) continue;
2454 for (const match of text.matchAll(/\{\$(?:I|INCLUDE)\s+['"]?([^'"}\s*]+)/gi)) {
2455 let name = match[1]!.replace(/\\/g, '/');
2456 name = name.slice(name.lastIndexOf('/') + 1).toLowerCase();
2457 if (!name.includes('.')) name += '.inc';
2458 const inc = nearest(projectFiles(context).byName.get(name) ?? [], filePath);
2459 if (inc && inc !== filePath && !includes.includes(inc)) includes.push(inc);
2460 }
2461 }
2462 }
2463 m.includes.set(filePath, includes);
2464 return includes;
2465}
2466
2467/** The Pascal file that includes an include file: of the forty nearest it, the nearest whose text does. */
2468function includerOf(incFile: string, context: ResolutionContext): string | null {

Callers 2

unitFilesOfFunction · 0.70
includerOfFunction · 0.70

Calls 7

memosFunction · 0.85
fileLinesFunction · 0.85
nearestFunction · 0.85
projectFilesFunction · 0.85
pushMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected