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

Function buildIndex

src/resolution/frameworks/cics.ts:34–54  ·  view source on GitHub ↗
(context: ResolutionContext)

Source from the content-addressed store, hash-verified

32const transidIndexes = new WeakMap<ResolutionContext, Map<string, string>>();
33
34function buildIndex(context: ResolutionContext): Map<string, string> {
35 const index = new Map<string, string>();
36 const dataNodes: Node[] = [
37 ...context.getNodesByKind('variable'),
38 ...context.getNodesByKind('field'),
39 ...context.getNodesByKind('constant'),
40 ];
41 for (const node of dataNodes) {
42 if (node.language !== 'cobol') continue;
43 if (!TRANID_NAME_RE.test(node.name)) continue;
44 const value = node.signature ? VALUE_LITERAL_RE.exec(node.signature) : null;
45 if (!value?.[1]) continue;
46 const tx = value[1].toUpperCase();
47 if (index.has(tx)) continue; // first declaration wins; collisions are rare and ambiguous
48 const moduleNode = context
49 .getNodesInFile(node.filePath)
50 .find((n) => n.kind === 'module' && n.language === 'cobol');
51 if (moduleNode) index.set(tx, moduleNode.id);
52 }
53 return index;
54}
55
56export const cicsResolver: FrameworkResolver = {
57 name: 'cics',

Callers 1

resolveFunction · 0.85

Calls 5

hasMethod · 0.80
getNodesByKindMethod · 0.65
execMethod · 0.65
getNodesInFileMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected