(content: string)
| 31 | }> {} |
| 32 | |
| 33 | const findAnnotation = (content: string): { pattern: string; offset: number } | undefined => { |
| 34 | const lines = content.split("\n") |
| 35 | |
| 36 | // Find the line containing the annotation |
| 37 | let annotationLine = -1 |
| 38 | let pattern: string | undefined |
| 39 | for (let i = 0; i < lines.length; i++) { |
| 40 | pattern = parseAnnotation(lines[i]) |
| 41 | if (pattern !== undefined) { |
| 42 | annotationLine = i |
| 43 | break |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | if (annotationLine === -1 || pattern === undefined) { |
| 48 | return undefined |
| 49 | } |
| 50 | |
| 51 | // Walk forwards to find the end of the comment block |
| 52 | let commentEnd = annotationLine |
| 53 | while (commentEnd < lines.length - 1 && lines[commentEnd + 1].trimStart().startsWith("//")) { |
| 54 | commentEnd++ |
| 55 | } |
| 56 | |
| 57 | return { pattern, offset: commentEnd + 1 } |
| 58 | } |
| 59 | |
| 60 | const parseAnnotation = (line: string): string | undefined => { |
| 61 | const match = line.match(/^\/\/\s*@barrel(?:\((.+?)\))?/) |
no test coverage detected