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

Function emitWriteRefs

src/extraction/languages/cobol.ts:280–296  ·  view source on GitHub ↗

* Emit a `references` ref for every data item a statement WRITES (MOVE TO, * ADD TO/GIVING, SUBTRACT FROM/GIVING, COMPUTE =). Write-sites are what an * impact query on a working-storage or copybook field needs: "what changes * WS-TOTAL" is the COBOL analogue of value-reference edges. Read operand

(
  statement: SyntaxNode,
  fields: string[],
  fromNodeId: string | undefined,
  ctx: ExtractorContext
)

Source from the content-addressed store, hash-verified

278 * impact value.
279 */
280function emitWriteRefs(
281 statement: SyntaxNode,
282 fields: string[],
283 fromNodeId: string | undefined,
284 ctx: ExtractorContext
285): void {
286 for (const field of fields) {
287 for (const target of statement.childrenForFieldName(field)) {
288 if (!target) continue;
289 const word = targetBaseName(target, ctx.source);
290 if (!word) continue;
291 const name = getNodeText(word, ctx.source).trim();
292 if (!name || SPECIAL_REGISTER_RE.test(name)) continue;
293 addRef(ctx, fromNodeId, name, 'references', word);
294 }
295 }
296}
297
298/**
299 * Collect call/import references from a statement subtree, attributed to the

Callers 1

collectRefsFunction · 0.85

Calls 3

getNodeTextFunction · 0.90
targetBaseNameFunction · 0.85
addRefFunction · 0.85

Tested by

no test coverage detected