(context: ResolutionContext)
| 32 | const transidIndexes = new WeakMap<ResolutionContext, Map<string, string>>(); |
| 33 | |
| 34 | function 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 | |
| 56 | export const cicsResolver: FrameworkResolver = { |
| 57 | name: 'cics', |
no test coverage detected