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

Function treeFor

src/graph/branch-guards.ts:189–211  ·  view source on GitHub ↗
(absPath: string, language: Language)

Source from the content-addressed store, hash-verified

187}
188
189async function treeFor(absPath: string, language: Language): Promise<CachedTree | null> {
190 let stat: fs.Stats;
191 try {
192 stat = fs.statSync(absPath);
193 } catch {
194 return null;
195 }
196 const key = `${language}:${stat.mtimeMs}:${stat.size}`;
197 const hit = treeCache.get(absPath);
198 if (hit && hit.key === key) return hit;
199 if (stat.size > MAX_PARSE_BYTES) return null;
200 let source: string;
201 try {
202 source = fs.readFileSync(absPath, 'utf8');
203 } catch {
204 return null;
205 }
206 const tree = await parse(source, language);
207 if (!tree) return null;
208 const entry = { key, tree, source };
209 remember(absPath, entry);
210 return entry;
211}
212
213async function parse(source: string, language: Language): Promise<Tree | null> {
214 try {

Callers 8

guardsForFileFunction · 0.85
callArgumentsForFileFunction · 0.85
callSitesForFileFunction · 0.85
triggersForFileFunction · 0.85
loopsForFileFunction · 0.85
returnsForFileFunction · 0.85
decoratorsForFileFunction · 0.85
memberTypesForFileFunction · 0.85

Calls 3

parseFunction · 0.70
rememberFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected