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

Function includesOf

src/resolution/pascal-scope.ts:910–929  ·  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

908
909/** The include files a Pascal file pulls in (`{$I name.inc}`, `{$INCLUDE name}`), each the one of that name nearest it. */
910function includesOf(filePath: string, context: ResolutionContext): string[] {
911 const m = memos(context);
912 let includes = m.includes.get(filePath);
913 if (includes) return includes;
914 includes = [];
915 if (PASCAL_SOURCE.test(filePath)) {
916 for (const text of fileLines(filePath, context)) {
917 if (!text.includes('{$') || !/\{\$i(?:nclude)?\s/i.test(text)) continue;
918 for (const match of text.matchAll(/\{\$(?:I|INCLUDE)\s+['"]?([^'"}\s*]+)/gi)) {
919 let name = match[1]!.replace(/\\/g, '/');
920 name = name.slice(name.lastIndexOf('/') + 1).toLowerCase();
921 if (!name.includes('.')) name += '.inc';
922 const inc = nearest(projectFiles(context).byName.get(name) ?? [], filePath);
923 if (inc && inc !== filePath && !includes.includes(inc)) includes.push(inc);
924 }
925 }
926 }
927 m.includes.set(filePath, includes);
928 return includes;
929}
930
931/** The Pascal file that includes an include file: of the forty nearest it, the nearest whose text does. */
932function 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