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

Function cppIncluders

src/resolution/cpp-includers.ts:184–207  ·  view source on GitHub ↗
(filePath: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

182 * include it: the translation units (and headers) it is part of.
183 */
184export function cppIncluders(filePath: string, context: ResolutionContext): ReadonlySet<string> {
185 const memo = memoFor(context);
186 const hit = memo.includers.get(filePath);
187 if (hit) return hit;
188 const byName = includesByName(context, memo);
189 const found = new Set<string>();
190 const queue = [filePath];
191 for (let i = 0; i < queue.length; i++) {
192 const target = queue[i]!;
193 const name = fileName(target);
194 const dot = name.lastIndexOf('.');
195 // `#include "foo"` can name `foo.h`: the include resolver tries extensions.
196 for (const spelled of dot > 0 ? [name, name.slice(0, dot)] : [name]) {
197 for (const include of byName.get(spelled) ?? []) {
198 if (include.file === filePath || found.has(include.file)) continue;
199 if (includedFile(include, context, memo) !== target) continue;
200 found.add(include.file);
201 queue.push(include.file);
202 }
203 }
204 }
205 memo.includers.set(filePath, found);
206 return found;
207}

Callers 4

definedByIncluderFunction · 0.90
declarationNodeFunction · 0.90
cMacroRenameFunction · 0.90
cppIncludedHeadersBesideFunction · 0.85

Calls 9

includesByNameFunction · 0.85
fileNameFunction · 0.85
includedFileFunction · 0.85
hasMethod · 0.80
pushMethod · 0.80
memoForFunction · 0.70
getMethod · 0.65
addMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected