First capture of `re` across the node's line span, or null.
(node: Node, re: RegExp, context: ResolutionContext)
| 223 | |
| 224 | /** First capture of `re` across the node's line span, or null. */ |
| 225 | function readNodeSpanMatch(node: Node, re: RegExp, context: ResolutionContext): string | null { |
| 226 | const lines = |
| 227 | context.getFileLines?.(node.filePath) ?? context.readFile(node.filePath)?.split('\n') ?? null; |
| 228 | if (!lines) return null; |
| 229 | const end = Math.min(node.endLine, lines.length); |
| 230 | for (let i = Math.max(node.startLine - 1, 0); i < end; i++) { |
| 231 | const m = lines[i]!.match(re); |
| 232 | if (m) return m[1]!; |
| 233 | } |
| 234 | return null; |
| 235 | } |
| 236 | |
| 237 | /** Directory of a stored (forward-slash, project-relative) path. */ |
| 238 | function dirOf(p: string): string { |
no test coverage detected