* Read a small window of source ending at `node.startLine`, used to * inspect Swift attribute annotations attached to a declaration. Returns * an empty string if the source can't be read.
(node: Node, context: ResolutionContext)
| 155 | * an empty string if the source can't be read. |
| 156 | */ |
| 157 | function declarationSourceWindow(node: Node, context: ResolutionContext): string { |
| 158 | const content = context.readFile(node.filePath); |
| 159 | if (!content) return ''; |
| 160 | const lines = content.split(/\r?\n/); |
| 161 | const startIdx = Math.max(0, node.startLine - 1 - SOURCE_PROBE_LINES); |
| 162 | const endIdx = Math.min(lines.length, node.startLine); |
| 163 | return lines.slice(startIdx, endIdx).join('\n'); |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Try to resolve a Swift caller's bare reference to an ObjC implementation. |
no test coverage detected