MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / sfcBlockLineRanges

Function sfcBlockLineRanges

src/extraction/sfc-script.ts:82–92  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

80 * covers nothing.
81 */
82export 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. */
95export function sfcFileNode(filePath: string, source: string, language: Language): Node {

Callers 4

getCoveredRangesMethod · 0.90
extractTemplateCallsMethod · 0.90

Calls 3

sfcElementHasBodyFunction · 0.85
pushMethod · 0.80
execMethod · 0.65

Tested by

no test coverage detected