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

Function isCppMacroDefinedAt

src/resolution/cpp-macro-visibility.ts:106–120  ·  view source on GitHub ↗
(
  name: string,
  file: string,
  line: number,
  language: UnresolvedRef['language'],
  context: ResolutionContext
)

Source from the content-addressed store, hash-verified

104 * REDISMODULE_CORE, and not in a module that includes the same header.
105 */
106export function isCppMacroDefinedAt(
107 name: string,
108 file: string,
109 line: number,
110 language: UnresolvedRef['language'],
111 context: ResolutionContext
112): boolean {
113 const cache = cacheFor(context);
114 const key = `${language}\0${file}\0${name}`;
115 let timeline = cache.watched.get(key);
116 if (!timeline) cache.watched.set(key, (timeline = walkTranslationUnit(file, language, context, cache, name)));
117 if (line >= timeline.cutoff) return false;
118 const before = (timeline.events.get(name) ?? []).filter((e) => e.line <= line);
119 return before.length > 0 && before[before.length - 1]!.defined === true;
120}
121
122function cacheFor(context: ResolutionContext): Cache {
123 let cache = memo.get(context);

Callers 1

cMacroRenameFunction · 0.90

Calls 4

cacheForFunction · 0.85
walkTranslationUnitFunction · 0.85
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected