* Lightweight ResolutionContext mock — implements only the methods the * bridge resolver actually calls. Anything else throws so a leaked call * surfaces loudly in tests.
(nodes: Node[], fileContents: Record<string, string> = {})
| 9 | * surfaces loudly in tests. |
| 10 | */ |
| 11 | function makeContext(nodes: Node[], fileContents: Record<string, string> = {}): ResolutionContext { |
| 12 | const byName = new Map<string, Node[]>(); |
| 13 | for (const n of nodes) { |
| 14 | const arr = byName.get(n.name); |
| 15 | if (arr) arr.push(n); |
| 16 | else byName.set(n.name, [n]); |
| 17 | } |
| 18 | const allFiles = new Set(nodes.map((n) => n.filePath)); |
| 19 | return { |
| 20 | getNodesInFile: (fp) => nodes.filter((n) => n.filePath === fp), |
| 21 | getNodesByName: (name) => byName.get(name) ?? [], |
| 22 | getNodesByQualifiedName: () => { throw new Error('not used'); }, |
| 23 | getNodesByKind: (kind) => nodes.filter((n) => n.kind === kind), |
| 24 | getNodesByLowerName: () => { throw new Error('not used'); }, |
| 25 | fileExists: (fp) => allFiles.has(fp), |
| 26 | readFile: (fp) => fileContents[fp] ?? null, |
| 27 | getProjectRoot: () => '/test', |
| 28 | getAllFiles: () => Array.from(allFiles), |
| 29 | getImportMappings: () => [], |
| 30 | }; |
| 31 | } |
| 32 | |
| 33 | function method(name: string, language: 'swift' | 'objc', filePath: string, startLine = 10): Node { |
| 34 | return { |
no test coverage detected