MCPcopy
hub / github.com/coder/mux / getCachedLibSourceFile

Function getCachedLibSourceFile

src/node/services/ptc/typeValidator.ts:45–60  ·  view source on GitHub ↗
(
  fileName: string,
  languageVersion: ts.ScriptTarget,
  readFile: () => string | undefined
)

Source from the content-addressed store, hash-verified

43 `${languageVersion}:${fileName}`;
44
45function getCachedLibSourceFile(
46 fileName: string,
47 languageVersion: ts.ScriptTarget,
48 readFile: () => string | undefined
49): ts.SourceFile | undefined {
50 const key = getLibCacheKey(fileName, languageVersion);
51 const cached = libSourceFileCache.get(key);
52 if (cached) return cached;
53
54 const contents = readFile();
55 if (!contents) return undefined;
56
57 const sourceFile = ts.createSourceFile(fileName, contents, languageVersion, true);
58 libSourceFileCache.set(key, sourceFile);
59 return sourceFile;
60}
61
62function getCachedMuxSourceFile(muxTypes: string, languageVersion: ts.ScriptTarget): ts.SourceFile {
63 const key = `${languageVersion}:${muxTypes}`;

Callers 1

createProgramForCodeFunction · 0.85

Calls 4

getLibCacheKeyFunction · 0.85
setMethod · 0.80
getMethod · 0.65
readFileFunction · 0.50

Tested by

no test coverage detected