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

Function handlePpDefine

src/extraction/languages/erlang.ts:175–196  ·  view source on GitHub ↗
(node: SyntaxNode, ctx: ExtractorContext)

Source from the content-addressed store, hash-verified

173}
174
175function handlePpDefine(node: SyntaxNode, ctx: ExtractorContext): boolean {
176 const lhs = getChildByField(node, 'lhs');
177 const nameNode = lhs ? getChildByField(lhs, 'name') : null;
178 if (!nameNode) return true;
179 const macro = ctx.createNode('constant', getNodeText(nameNode, ctx.source), node, {
180 signature: collapseWs(getNodeText(node, ctx.source)).slice(0, 200),
181 });
182 // The replacement's calls execute at expansion sites, but attributing them
183 // to the MACRO node keeps them true exactly once: `-define(LOG_AUDIT(E),
184 // audit_logger:log(E))` gives the LOG_AUDIT constant a `calls` edge to the
185 // logger, and each `?LOG_AUDIT(...)` use site links to the constant (see the
186 // macro_call_expr case in extractCall) — so the chain
187 // `caller → LOG_AUDIT → audit_logger:log` traverses without minting a
188 // per-use duplicate of the body's calls.
189 const replacement = getChildByField(node, 'replacement');
190 if (macro && replacement) {
191 ctx.pushScope(macro.id);
192 ctx.visitFunctionBody(replacement, macro.id);
193 ctx.popScope();
194 }
195 return true;
196}
197
198function handleBehaviour(node: SyntaxNode, ctx: ExtractorContext): boolean {
199 const nameNode = getChildByField(node, 'name');

Callers 1

erlang.tsFile · 0.85

Calls 7

getChildByFieldFunction · 0.90
getNodeTextFunction · 0.90
collapseWsFunction · 0.85
pushScopeMethod · 0.80
popScopeMethod · 0.80
createNodeMethod · 0.65
visitFunctionBodyMethod · 0.65

Tested by

no test coverage detected