(source: string)
| 80 | * covers nothing. |
| 81 | */ |
| 82 | export function sfcBlockLineRanges(source: string): Array<[number, number]> { |
| 83 | const ranges: Array<[number, number]> = []; |
| 84 | const elements = new RegExp(SFC_SCRIPT_OR_STYLE_ELEMENT); |
| 85 | let match: RegExpExecArray | null; |
| 86 | while ((match = elements.exec(source)) !== null) { |
| 87 | if (!sfcElementHasBody(match[0])) continue; |
| 88 | const startLine = (source.substring(0, match.index).match(/\n/g) || []).length; |
| 89 | ranges.push([startLine, startLine + (match[0].match(/\n/g) || []).length]); |
| 90 | } |
| 91 | return ranges; |
| 92 | } |
| 93 | |
| 94 | /** The SFC's own file node — the whole file, as the tree-sitter extractor makes one. */ |
| 95 | export function sfcFileNode(filePath: string, source: string, language: Language): Node { |
no test coverage detected